Created
June 20, 2015 17:15
-
-
Save akondas/3dffd9813cca1f946a99 to your computer and use it in GitHub Desktop.
Get data from command in CQRS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// example 1 | |
class ProductController | |
{ | |
public function createProductAction(Request $request) | |
{ | |
$responder = new CreateProductResponder(); | |
$this->get('command_bus')->handle( | |
new CreateProductCommand('Foo', $responder) | |
); | |
$responder->id; | |
} | |
} | |
// example 2 | |
class ProductController | |
{ | |
public function createProductAction(Request $request) | |
{ | |
$bus = $this->get('command_bus'); | |
$bus->handle(new CreateProductCommand('Foo')); | |
$bus->responder->id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment