Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add QueryDispatcher/CommandDispatcher
- Loading branch information
Showing
19 changed files
with
310 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace ICanBoogie\MessageBus; | ||
|
||
interface CommandDispatcher extends Dispatcher | ||
{ | ||
/** | ||
* @param object $command | ||
* | ||
* @return mixed | ||
*/ | ||
public function dispatch(object $command); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ICanBoogie package. | ||
* | ||
* (c) Olivier Laviale <olivier.laviale@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ICanBoogie\MessageBus\PSR; | ||
|
||
use ICanBoogie\MessageBus\CommandDispatcher as Contract; | ||
use ICanBoogie\MessageBus\SimpleDispatcher; | ||
|
||
class CommandDispatcher extends SimpleDispatcher implements Contract | ||
{ | ||
public function __construct(CommandHandlerProvider $handler_provider) | ||
{ | ||
parent::__construct($handler_provider); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ICanBoogie package. | ||
* | ||
* (c) Olivier Laviale <olivier.laviale@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ICanBoogie\MessageBus\PSR; | ||
|
||
class CommandHandlerProvider extends ContainerHandlerProvider | ||
{ | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ICanBoogie package. | ||
* | ||
* (c) Olivier Laviale <olivier.laviale@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ICanBoogie\MessageBus\PSR; | ||
|
||
use ICanBoogie\MessageBus\QueryDispatcher as Contract; | ||
use ICanBoogie\MessageBus\SimpleDispatcher; | ||
|
||
class QueryDispatcher extends SimpleDispatcher implements Contract | ||
{ | ||
public function __construct(QueryHandlerProvider $handler_provider) | ||
{ | ||
parent::__construct($handler_provider); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ICanBoogie package. | ||
* | ||
* (c) Olivier Laviale <olivier.laviale@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ICanBoogie\MessageBus\PSR; | ||
|
||
class QueryHandlerProvider extends ContainerHandlerProvider | ||
{ | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace ICanBoogie\MessageBus; | ||
|
||
interface QueryDispatcher extends Dispatcher | ||
{ | ||
/** | ||
* @param object $query | ||
* | ||
* @return mixed | ||
*/ | ||
public function dispatch(object $query); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ICanBoogie package. | ||
* | ||
* (c) Olivier Laviale <olivier.laviale@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ICanBoogie\MessageBus\Symfony; | ||
|
||
use ICanBoogie\MessageBus\PSR\CommandHandlerProvider; | ||
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class CommandHandlerProviderPass extends HandlerProviderPass | ||
{ | ||
const DEFAULT_SERVICE_ID = CommandHandlerProvider::class; | ||
const DEFAULT_HANDLER_TAG = 'command_dispatcher.handler'; | ||
const DEFAULT_QUERY_PROPERTY = 'command'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $service_id; | ||
|
||
public function __construct( | ||
string $service_id = self::DEFAULT_SERVICE_ID, | ||
string $handler_tag = self::DEFAULT_HANDLER_TAG, | ||
string $command_property = self::DEFAULT_QUERY_PROPERTY | ||
) { | ||
$this->service_id = $service_id; | ||
|
||
parent::__construct($service_id, $handler_tag, $command_property); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
[ $mapping, $ref_map ] = $this->collectHandlers($container); | ||
|
||
$container | ||
->register($this->service_id, CommandHandlerProvider::class) | ||
->setArguments([ | ||
$mapping, | ||
ServiceLocatorTagPass::register($container, $ref_map) | ||
]); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ICanBoogie package. | ||
* | ||
* (c) Olivier Laviale <olivier.laviale@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ICanBoogie\MessageBus\Symfony; | ||
|
||
use ICanBoogie\MessageBus\PSR\QueryHandlerProvider; | ||
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class QueryHandlerProviderPass extends HandlerProviderPass | ||
{ | ||
const DEFAULT_SERVICE_ID = QueryHandlerProvider::class; | ||
const DEFAULT_HANDLER_TAG = 'query_dispatcher.handler'; | ||
const DEFAULT_QUERY_PROPERTY = 'query'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $service_id; | ||
|
||
public function __construct( | ||
string $service_id = self::DEFAULT_SERVICE_ID, | ||
string $handler_tag = self::DEFAULT_HANDLER_TAG, | ||
string $query_property = self::DEFAULT_QUERY_PROPERTY | ||
) { | ||
$this->service_id = $service_id; | ||
|
||
parent::__construct($service_id, $handler_tag, $query_property); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
[ $mapping, $ref_map ] = $this->collectHandlers($container); | ||
|
||
$container | ||
->register($this->service_id, QueryHandlerProvider::class) | ||
->setArguments([ | ||
$mapping, | ||
ServiceLocatorTagPass::register($container, $ref_map) | ||
]); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace ICanBoogie\MessageBus\Symfony; | ||
|
||
class CommandA | ||
{ | ||
|
||
} |
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
Oops, something went wrong.