astina / domain-events-bundle
该软件包已被废弃,不再维护。未建议替代软件包。
此软件包最新版本(0.1.1)的许可证信息不可用。
将服务配置为Doctrine域事件监听器。
0.1.1
2013-04-27 09:45 UTC
Requires
- doctrine/doctrine-bundle: dev-entity_listener_resolver
This package is not auto-updated.
Last update: 2022-07-18 19:42:54 UTC
README
将服务配置为Doctrine域事件监听器。
注意:此软件包尚未准备好用于生产环境,因为它需要DoctrineBundle的主版本。
安装
步骤 1:添加到 composer.json
"require": { "astina/domain-events-bundle":"dev-master", }
步骤 2:启用软件包
在内核中启用软件包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Astina\Bundle\DomainEventsBundle\AstinaDomainEventsBundle(), ); }
##使用方法
创建订阅者服务
class ProductSupplyWatcher { public function preUpdate(ProductSupply $supply, PreUpdateEventArgs $event) { // do stuff } }
有关(可选)$event参数的更多信息,请参阅Doctrine关于实体监听器的文档。
<service id="product_supply_watcher" class="Astina\Bundle\SandboxBundle\Foo\ProductSupplyWatcher"> <argument type="service" id="some_service" /> </service>
配置域事件订阅者
astina_domain_events: subscribers: product_supply_watcher: # this is the service id entity: Astina\Bundle\ShopBundle\Model\ProductSupply # entity class events: [ preUpdate ] # list of events to listen to
注意订阅者服务中的方法名称与事件名称相对应。
可用事件
- prePersist
- postPersist
- preUpdate
- postUpdate
- preRemove
- postRemove
- preFlush
- postLoad
##待办事项 添加订阅特定字段更改的可能性。