承接 heimrichhannot/contao-exporter-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

heimrichhannot/contao-exporter-bundle

Composer 安装命令:

composer require heimrichhannot/contao-exporter-bundle

包简介

A backend module for exporting any contao entity to file.

README 文档

README

A module for exporting any contao entity to file.

Contao Exporter Bundle Backend Config Preview

Export config preview

Features

  • export entities and list of entities
  • easily add backend modules to your application/extension or use the frontendmodule
  • expandable exporter architecture
  • included exporter:
    • csv
    • Excel (xlsx)
    • pdf
    • Media files (export media files assoziated with an entity as archive(zip))

Csv and Excel export are archived by Spout library. PDF export is archived by mPDF library. This library comes not as dependency and therefore must be added to your bundle/project dependencies to archvie pdf export functionality.

Technical instruction

Install

Install with composer:

composer require heimrichhannot/contao-exporter-bundle

If you want to use the pdf exporter, add "mpdf/mpdf":"^7.0" to your composer dependencies.

Backend export

Step 1

Define your global operation in your entity's dca as follows:

'global_operations' => [
    'export_csv' => \Contao\System::getContainer()->get('huh.exporter.action.backendexport')
        ->getGlobalOperation('export_csv',$GLOBALS['TL_LANG']['MSC']['export_csv'])
],

Step 2

Add your backend module in your entity's config.php as follows:

$GLOBALS['BE_MOD']['mygroup']['name'] = [
    'export_csv' => ['huh.exporter.action.backendexport', 'export'],
    'tables' => ['tl_name'],
];

Step 3

Create a configuration for your export by using the exporter's backend module (group devtools).

Frontend

You can use the included frontend module to add an easy export functionality.

You can also use frontendedit or 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!

You can also create an custom implementation for your extension:

  1. Create a configuration for your export by using the exporter's backend module (group devtools).
  2. Call export() of huh.exporter.action.frontendexport service in your module:
/** @var Symfony\Component\DependencyInjection\ContainerInterface $container */
$container->get('huh.exporter.action.export')->export($config: ExporterModel, $entity: int|string, $fields = []: array);

Developers

Upgrade from exporter module

Please see Upgrade Instructions.

Events

You can hook into the export with given event. Please check Symfony Event Documentation if you don't know how.

Eventname Event-ID Description
Before Export huh.exporter.event.before_export Fired before start of export. Customize file name and file path.
Before Build Query huh.exporter.event.before_build_query Fired before building and executing the query for collecting list content.
Modify Table Header field huh.exporter.event.modifyheaderfields Modify header field values in tables.
Modify Table field value huh.exporter.event.modifyfieldvalue Fired before writing a table value to the table object (e.g. spreadsheet).
Modify Media File Name huh.exporter.event.modifymediafilename Modify media file before adding to archive (filename and file object).

Add custom exporter

You can add custom exporter to add additional file types or functionality.

Your 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.

services:
  _defaults:
    autowire: true

  _instanceof:
    HeimrichHannot\ContaoExporterBundle\Exporter\ExporterInterface:
      tags: ['huh_exporter.exporter']
      lazy: true
      
  Your\Exporter\Class: ~

Custom field selection

You can pass an array of fields to export() of an exporter. Those fields will be used, when exporting an item.

There are two options:

  1. A list of field names. Example: ['firstname','lastname','age']
  2. A field list with labels and values. Should be structured as shown:
<?php 
$fields = [
    'field1' => [
        'raw' => '', // raw field value
        'inputType' => '', // field input type 
        'value' => '', // formatted field value
        'formatted' => '', // formatted field value
        'label' => '', // formatted field value
    ],
    // ...
];

Pdf

To use Pdf export, you first need to install mPDF.

Templates

You 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.

Fonts

To add custom Pdf font, please see the corresponding chapters in Utils Bundle docs and the mPDF Docs. Afterwards you can add the folders in the exporter config.

heimrichhannot/contao-exporter-bundle 适用场景与选型建议

heimrichhannot/contao-exporter-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.34k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「excel」 「csv」 「bundle」 「backend」 「export」 「developer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 heimrichhannot/contao-exporter-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 heimrichhannot/contao-exporter-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 heimrichhannot/contao-exporter-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 26
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 1
  • Watchers: 5
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2018-07-25