ibrows/association-resolver-bundle
Composer 安装命令:
composer require ibrows/association-resolver-bundle
包简介
Resolve relations over annotations
README 文档
README
This Bundle is now stored here: https://gitlab.pwc-digital.ch/ec/bundles/IbrowsAssociationResolverBundle
iBrows Association Bundle
A simple bundle to resolve associations on entities when they'll be imported from an external sourceCreate an annotation
See Annotation/OneToMany.phpIn this case I'm going to create a new OneToMany-annotation for this bundle. Therefore I create a new class called OneToMany in the 'Annotation' folder
and annotate the class with @Annotation and extend it from the AbstractAssociation
If you need to add some properties which can be configured in the annotation create a public property in the Annotation and create the getter/setter
Create the resolver
See Resolver/Type/OneToMany.phpTo handle the entity with our annotation @OneToMany we have to create a resolver with the exact same name as the annotation class name. Our resolver extends the AbstractResolver to handle the annotated entity correctly. While extending the AbstractResolver we have to implement an abstract function to handle an entity and recive all the configurated properties.
/**
* @param ResultBag $resultBag
* @param AssociationMappingInfoInterface $mappingInfo
* @param string $propertyName
* @param mixed $entity
* @param OutputInterface $output
* @return ResolverInterface
*/
public function resolveAssociation(
ResultBag $resultBag,
AssociationMappingInfoInterface $mappingInfo,
$propertyName,
$entity,
OutputInterface $output
)
in the function body we extract the data from the mappinginfo for further operations. Inside the MappingInfo object where two properties. The Annotation and the Metadata. The Annotation object holds all the data which can be configured in the annotation. In our case we have 2 properties
public $collectionAddFunctionName; public $collectionRemoveFunctionName;
collectionAddFunctionName to customize the add function. If this property is not set the method name will be generated with an 'add' as prefix and the propertyname as suffix
collectionRemoveFunctionName to customize the remove function. If this property is not set the method name will be generated with an 'remove' as prefix and the propertyname as suffix
The Service
To make the resolver functional you have to register the resolver as a service in the service.xml<service id="ibrows_associationresolver.resolver.onetoone" class="Ibrows\AssociationResolver\Resolver\Type\OneToOne">
<argument type="service" id="doctrine.orm.entity_manager" />
<tag priority="-20" name="ibrows_associationresolver.resolverchain" />
<call method="setSoftdeletable">
<argument>%ibrows_associationresolver.softdelete%</argument>
</call>
<call method="setSoftdeletableGetter">
<argument>%ibrows_associationresolver.softdeletegetter%</argument>
</call>
</service>
´
The tag defines the position in the chain.
ibrows/association-resolver-bundle 适用场景与选型建议
ibrows/association-resolver-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.06k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2013 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「annotation」 「resolver」 「ibrows」 「association」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ibrows/association-resolver-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ibrows/association-resolver-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ibrows/association-resolver-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Type transformers, normalizers and resolvers.
Manage Sonata Form, Data, List and ShowMapper over annotations
resolve openapi keywords
PhpPlaisio: Company Resolver
Symfony bundle to add arbitrary metadata to classes and their constants by annotation
PhpPlaisio: Uni Company Resolver
统计信息
- 总下载量: 12.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-02-20