Skip to content

Instantly share code, notes, and snippets.

@akondas
Created June 20, 2015 17:15
Show Gist options
  • Save akondas/3dffd9813cca1f946a99 to your computer and use it in GitHub Desktop.
Save akondas/3dffd9813cca1f946a99 to your computer and use it in GitHub Desktop.
Get data from command in CQRS
<?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