-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Jeckel-Lab/command-bus
Command bus
- Loading branch information
Showing
6 changed files
with
113 additions
and
5 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,19 @@ | ||
parameters: | ||
tasks: | ||
phpcs: null | ||
phpmd: | ||
whitelist_patterns: | ||
- /^src\/(.*)/ | ||
ruleset: | ||
- ./ruleset.xml | ||
psalm: | ||
config: psalm.xml | ||
no_cache: true | ||
report: ~ | ||
# ignore_patterns: | ||
# - /^tests/ | ||
threads: 1 | ||
triggered_by: ['php'] | ||
show_info: true | ||
|
||
phpunit: null |
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,21 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="My first PHPMD rule set" | ||
xmlns="http://pmd.sf.net/ruleset/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 | ||
http://pmd.sf.net/ruleset_xml_schema.xsd" | ||
xsi:noNamespaceSchemaLocation=" | ||
http://pmd.sf.net/ruleset_xml_schema.xsd"> | ||
<description> | ||
My custom rule set that checks my code... | ||
</description> | ||
|
||
<rule ref="rulesets/cleancode.xml"> | ||
<exclude name="IfStatementAssignment" /> | ||
</rule> | ||
|
||
<rule ref="rulesets/codesize.xml" /> | ||
<rule ref="rulesets/design.xml" /> | ||
<rule ref="rulesets/naming.xml" /> | ||
<rule ref="rulesets/unusedcode.xml" /> | ||
</ruleset> |
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,52 @@ | ||
<?php | ||
|
||
/** | ||
* @author Julien Mercier-Rojas <[email protected]> | ||
* Created at : 03/02/2020 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JeckelLab\CommandDispatcherBundle\CommandBus\Decorator; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use JeckelLab\CommandDispatcher\Command\CommandInterface; | ||
use JeckelLab\CommandDispatcher\CommandBus\CommandBusInterface; | ||
use JeckelLab\CommandDispatcher\CommandResponse\CommandResponseInterface; | ||
|
||
/** | ||
* Class EntityFlushDecorator | ||
* @package App\Core\CommandBus | ||
*/ | ||
class EntityFlushDecorator implements CommandBusInterface | ||
{ | ||
/** @var CommandBusInterface */ | ||
protected $next; | ||
|
||
/** @var EntityManagerInterface */ | ||
protected $entityManager; | ||
|
||
/** | ||
* EntityFlushDecorator constructor. | ||
* @param CommandBusInterface $next | ||
* @param EntityManagerInterface $entityManager | ||
*/ | ||
public function __construct(CommandBusInterface $next, EntityManagerInterface $entityManager) | ||
{ | ||
$this->next = $next; | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
/** | ||
* @param CommandInterface $command | ||
* @return CommandResponseInterface | ||
*/ | ||
public function dispatch(CommandInterface $command): CommandResponseInterface | ||
{ | ||
$response = $this->next->dispatch($command); | ||
|
||
$this->entityManager->flush(); | ||
|
||
return $response; | ||
} | ||
} |
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