{"id":20961760,"url":"https://github.com/heimrichhannot/contao-exporter-bundle","last_synced_at":"2025-05-14T07:31:00.318Z","repository":{"id":32777301,"uuid":"141121566","full_name":"heimrichhannot/contao-exporter-bundle","owner":"heimrichhannot","description":"A backend module for exporting any contao entity to file.","archived":false,"fork":false,"pushed_at":"2024-04-08T12:05:41.000Z","size":325,"stargazers_count":1,"open_issues_count":7,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-24T13:10:10.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heimrichhannot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-07-16T10:07:34.000Z","updated_at":"2022-07-20T10:21:01.000Z","dependencies_parsed_at":"2024-03-20T16:09:53.080Z","dependency_job_id":null,"html_url":"https://github.com/heimrichhannot/contao-exporter-bundle","commit_stats":{"total_commits":51,"total_committers":8,"mean_commits":6.375,"dds":"0.43137254901960786","last_synced_commit":"28e1c72f6d4d8be64e5a084a1aff98f0237752f8"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fcontao-exporter-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fcontao-exporter-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fcontao-exporter-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fcontao-exporter-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heimrichhannot","download_url":"https://codeload.github.com/heimrichhannot/contao-exporter-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254094839,"owners_count":22013648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T02:16:42.625Z","updated_at":"2025-05-14T07:30:58.908Z","avatar_url":"https://github.com/heimrichhannot.png","language":"PHP","readme":"# Contao Exporter Bundle \n\nA module for exporting any contao entity to file.\n\n![Contao Exporter Bundle Backend Config Preview](docs/img/screenshot.png)\n\n*Export config preview*\n\n## Features\n\n- export entities and list of entities\n- easily add backend modules to your application/extension or use the frontendmodule\n- expandable exporter architecture\n- included exporter:\n    - csv\n    - Excel (xlsx)\n    - pdf\n    - Media files (export media files assoziated with an entity as archive(zip))\n    \nCsv and Excel export are archived by [Spout library](https://github.com/box/spout).\nPDF export is archived by [mPDF library](https://github.com/mpdf/mpdf). This library comes not as dependency and therefore must be added to your bundle/project dependencies to archvie pdf export functionality.\n\n## Technical instruction\n\n### Install \n\nInstall with composer:\n\n```\ncomposer require heimrichhannot/contao-exporter-bundle\n```\n\nIf you want to use the pdf exporter, add `\"mpdf/mpdf\":\"^7.0\"` to your composer dependencies.\n\n### Backend export\n\n#### Step 1\nDefine your global operation in your entity's dca as follows:\n\n```php\n'global_operations' =\u003e [\n    'export_csv' =\u003e \\Contao\\System::getContainer()-\u003eget('huh.exporter.action.backendexport')\n        -\u003egetGlobalOperation('export_csv',$GLOBALS['TL_LANG']['MSC']['export_csv'])\n],\n```\n\n#### Step 2\nAdd your backend module in your entity's config.php as follows:\n\n```php\n$GLOBALS['BE_MOD']['mygroup']['name'] = [\n    'export_csv' =\u003e ['huh.exporter.action.backendexport', 'export'],\n    'tables' =\u003e ['tl_name'],\n];\n```\n\n#### Step 3\nCreate a configuration for your export by using the exporter's backend module (group devtools).\n\n### Frontend\nYou can use the included frontend module to add an easy export functionality. \n\nYou can also use [frontendedit](https://github.com/heimrichhannot/contao-frontendedit) or [formhybrid_list](https://github.com/heimrichhannot/contao-formhybrid_list) in order to easily create a module for manipulating your entities in the frontend. It already contains a function to export entities after submission!\n\nYou can also create an custom implementation for your extension:\n\n1) Create a configuration for your export by using the exporter's backend module (group devtools).\n2) Call `export()` of `huh.exporter.action.frontendexport` service in your module:\n\n```php\n/** @var Symfony\\Component\\DependencyInjection\\ContainerInterface $container */\n$container-\u003eget('huh.exporter.action.export')-\u003eexport($config: ExporterModel, $entity: int|string, $fields = []: array);\n```\n\n## Developers\n\n### Upgrade from exporter module\n\nPlease see [Upgrade Instructions](UPGRADE.md).\n\n### Events\n\nYou can hook into the export with given event. Please check [Symfony Event Documentation](https://symfony.com/doc/3.4/event_dispatcher.html) if you don't know how. \n\nEventname                 | Event-ID                              | Description\n--------------------------|---------------------------------------|------------\nBefore Export             | huh.exporter.event.before_export      | Fired before start of export. Customize file name and file path.\nBefore Build Query        | huh.exporter.event.before_build_query | Fired before building and executing the query for collecting list content. \nModify Table Header field | huh.exporter.event.modifyheaderfields | Modify header field values in tables.\nModify Table field value  | huh.exporter.event.modifyfieldvalue   | Fired before writing a table value to the table object (e.g. spreadsheet).\nModify Media File Name    | huh.exporter.event.modifymediafilename| Modify media file before adding to archive (filename and file object). \n\n### Add custom exporter\n\nYou can add custom exporter to add additional file types or functionality. \n\nYour exporter class must implement `ExporterInterface` and must be registered in the container with the `huh_exporter.exporter` service tag. We recommend to extend `AbstractExporter`, because it already has most of the mechanics implemented. \n\n```\nservices:\n  _defaults:\n    autowire: true\n\n  _instanceof:\n    HeimrichHannot\\ContaoExporterBundle\\Exporter\\ExporterInterface:\n      tags: ['huh_exporter.exporter']\n      lazy: true\n      \n  Your\\Exporter\\Class: ~\n```\n\n### Custom field selection\n\nYou can pass an array of fields to `export()` of an exporter. Those fields will be used, when exporting an item.\n\nThere are two options:\n1) A list of field names. Example: `['firstname','lastname','age']`\n2) A field list with labels and values. Should be structured as shown:\n\n```php\n\u003c?php \n$fields = [\n    'field1' =\u003e [\n        'raw' =\u003e '', // raw field value\n        'inputType' =\u003e '', // field input type \n        'value' =\u003e '', // formatted field value\n        'formatted' =\u003e '', // formatted field value\n        'label' =\u003e '', // formatted field value\n    ],\n    // ...\n];\n\n```\n\n### Pdf\n\nTo use Pdf export, you first need to install [mPDF][1].\n\n#### Templates\n\nYou can overwrite the pdf output template. Templates are written in Twig and name should start with `exporter_pdf_`. See `exporter_pdf_item_default.html.twig` for a working example.\n\n#### Fonts\n\nTo add custom Pdf font, please see the corresponding chapters in [Utils Bundle docs][3] and the [mPDF Docs][4]. Afterwards you can add the folders in the exporter config.\n\n[1]: https://mpdf.github.io\n[3]: https://github.com/heimrichhannot/contao-utils-bundle/blob/master/docs/utils/pdf/pdf_writer.md#use-custom-fonts\n[4]: https://mpdf.github.io/fonts-languages/fonts-in-mpdf-7-x.html\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimrichhannot%2Fcontao-exporter-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheimrichhannot%2Fcontao-exporter-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimrichhannot%2Fcontao-exporter-bundle/lists"}