adamstipak/nette-cqrs-commands
最新稳定版本:1.0.0
Composer 安装命令:
composer require adamstipak/nette-cqrs-commands
包简介
Simple CQRS Commands for Nette Framework
关键字:
README 文档
README
###Connect Commands with services in Nette.
This extension provide a simle implementation of CQRS commands.
Installation:
The best way to install Nette-CQRS-Commands is using Composer:
$ composer require adamstipak/nette-cqrs-commands
Usage:
Example of Command:
use SimpleBus\Command\Command; class FooCommand implements Command { public function __construct(...) { // your code } /** * @return string */ public function name() { return 'foo'; // identificator of command } }
Example of CommandHandler:
use SimpleBus\Command\Command; use SimpleBus\Command\Handler\CommandHandler; class FooCommandHandler implements CommandHandler { /** * @param FooCommand $command */ public function handle(Command $command) { // $command is instance of FooCommand } }
Register all things in config.neon.
services: fooCommandHandler: FooCommandHandler # your service extensions: events: AdamStipak\Commands\DI\CommandsExtension commands: # mapping commands to handlers handlers: foo: @fooCommandHandler # configuration (here is default values so you can avoid this lines) commandResolver: \AdamStipak\Commands\Command\DefaultCommandResolver handlerResolver: \AdamStipak\Commands\Handler\DefaultHandlerResolver bus: \AdamStipak\Commands\Bus\DefaultBus
Example of Presenter:
class FooPresenter extends Nette\Application\UI\Presenter { /** * @var AdamStipak\Commands\Bus\DefaultBus * @inject */ public $commands; public function actionBar() { // ... your code here ... $this->commands->handle(new FooCommand(...)); // send the command to command bus (model) } }
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-10