php-ddd / php-ddd-bundle
事件管理库
v1.0.0
2014-12-31 18:15 UTC
Requires
- php: >=5.3.3
- php-ddd/command: ~1.0
- php-ddd/domain-event: ~1.0
- symfony/console: ~2.3
- symfony/framework-bundle: ~2.3
Requires (Dev)
- fabpot/php-cs-fixer: dev-master
- phpunit/phpunit: 4.0.*
This package is not auto-updated.
Last update: 2024-09-14 16:50:09 UTC
README
PhpDDDBundle为在Symfony应用程序中集成php-ddd/domain-event和php-ddd/command提供了一些工具。
特性
- SequentialCommandBus和CommandHandlerLocator的服务
- EventBus和EventListenerLocator的服务
- 一个服务标签,方便将Command与CommandHandler关联
- 一个服务标签,方便将Event与EventListener关联
- 一个
php-ddd:command-bus:debug
Symfony命令,用于列出给定CommandBus的每个Command/CommandHandler - 一个
php-ddd:event-bus:debug
Symfony命令,用于列出附加到给定EventBus的每个Event/EventListener
使用方法
使用标签将CommandHandler关联到Command
将CommandHandler与Command关联的最简单方法是使用服务标签php_ddd.command_handler
在CommandHandler上
# services.yml services: my.command_handler.foo: class: My/CommandHandler/FooCommandHandler tags: - { name: php_ddd.command_handler, command: My/Command/Foo }
CommandHandler将自动注册到phpddd_command.handler_locator
服务中,该服务对应于CommandHandlerLocator。然后,这个CommandHandlerLocator会被传递到phpddd_command.bus
服务中,默认情况下对应于SequentialCommandBus。
使用标签添加监听特定事件的EventListener
这和CommandHandler与Command的关联方式相同
# services.yml services: my.listener.bar: class: My/EventListener/BarEventListener tags: - { name: php_ddd.event_listener, event: Other/Event/Bar }
EventListener将自动注册到phpddd_event.listener_locator
服务中,该服务对应于EventListenerLocator。然后,这个EventListener会被传递到phpddd_event.bus
服务中,默认情况下对应于EventBus。