transformers/mapping-transformer
Composer 安装命令:
composer require transformers/mapping-transformer
包简介
Integrates Mapper to transform array collections using Mappings.
README 文档
README
MappingTransformer integrates Mapper into Porter to support data transformations using Mapping objects. A full discussion of Mapper is beyond the scope of this document but the linked repository contains comprehensive documentation. MappingTransformer builds on Mapper by providing a powerful mapping strategy called SubImport.
Sub-imports
The SubImport strategy provides a way to join data sets together. A mapping may contain any number of sub-imports, each of which may receive a different ImportSpecification. A sub-import causes Porter to begin a new import operation and thus supports all import options without limitation, including importing from different providers and applying a separate mapping to each sub-import.
Signature
SubImport(ImportSpecification|callable $specificationOrCallback)
$specificationOrCallback– Either anImportSpecificationinstance orcallablethat returns such an instance.
ImportSpecification Example
The following example imports MyImportSpecification and copies the foo field from the input data into the output mapping. Next it performs a sub-import using MyDetailsSpecification and stores the result in the details key of the output mapping.
$records = $porter->import( (new MyImportSpecification) ->setMapping(new AnonymousMapping([ 'foo' => new Copy('foo'), 'details' => new SubImport(MyDetailsSpecification), ])) );
Callback example
The following example is the same as the previous except MyDetailsSpecification now requires an identifier that is copied from details_id present in the input data. This is only possible using a callback since we cannot inject strategies inside specifications.
$records = $porter->import( (new MyImportSpecification) ->setMapping(new AnonymousMapping([ 'foo' => new Copy('foo'), 'details' => new SubImport( function (array $record) { return new MyDetailsSpecification($record['details_id']); } ), ])) );
transformers/mapping-transformer 适用场景与选型建议
transformers/mapping-transformer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 80.67k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 transformers/mapping-transformer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 transformers/mapping-transformer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 80.67k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 23
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2017-01-29