diff --git a/.travis.yml b/.travis.yml index 056690f..5d1b869 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,36 @@ language: php + php: - 7.1 - 7.2 - 7.3 +cache: + directories: + - $HOME/.composer/cache + +matrix: + include: + - php: 7.1 + env: 'COMPOSER_FLAGS="--prefer-lowest --prefer-stable"' + - php: 7.1 + env: 'COMPOSER_FLAGS="--prefer-stable"' + - php: 7.2 + env: 'COMPOSER_FLAGS="--prefer-lowest --prefer-stable"' + - php: 7.2 + env: 'COMPOSER_FLAGS="--prefer-stable"' + - php: 7.3 + env: 'COMPOSER_FLAGS="--prefer-lowest --prefer-stable"' + - php: 7.3 + env: 'COMPOSER_FLAGS="--prefer-stable"' + branches: only: - master + - v1; install: - - composer install --prefer-source + - composer update --prefer-source $COMPOSER_FLAGS script: - ./vendor/bin/phpunit -c phpunit.xml.dist diff --git a/Tests/Event/DelayedListenerTest.php b/Tests/Event/DelayedListenerTest.php index 5020af6..ad42253 100644 --- a/Tests/Event/DelayedListenerTest.php +++ b/Tests/Event/DelayedListenerTest.php @@ -83,7 +83,7 @@ public function after() return [\FakeModel::class => 'action']; } - public function execute(\Biig\Component\Domain\Event\DomainEvent $event) + public function execute(DomainEvent $event) { $model = new \FakeModel(); $model->setFoo('RulePostPersist'); @@ -173,7 +173,7 @@ public function after() return [\FakeModel::class => 'action']; } - public function execute(\Biig\Component\Domain\Event\DomainEvent $event) + public function execute(DomainEvent $event) { // Count times of execution $event->getSubject()->setFoo($event->getSubject()->getFoo() + 1); diff --git a/Tests/Event/DomainEventDispatcherTest.php b/Tests/Event/DomainEventDispatcherTest.php index 9e67691..4751940 100644 --- a/Tests/Event/DomainEventDispatcherTest.php +++ b/Tests/Event/DomainEventDispatcherTest.php @@ -41,7 +41,7 @@ public function on() public function setFoo($foo) { $this->foo = $foo; - $this->dispatch('foo.changed', new DomainEvent($this)); + $this->dispatch(new DomainEvent($this), 'foo.changed'); } public function getFoo() @@ -94,13 +94,13 @@ public function on() public function setFoo($foo) { $this->foo = $foo; - $this->dispatch('foo.changed', new DomainEvent($this)); + $this->dispatch(new DomainEvent($this), 'foo.changed'); } public function setBar($bar) { $this->bar = $bar; - $this->dispatch('bar.changed', new DomainEvent($this)); + $this->dispatch(new DomainEvent($this), 'bar.changed'); } public function getFoo() diff --git a/Tests/Event/DomainEventTest.php b/Tests/Event/DomainEventTest.php index fe9ef0e..86d8c6d 100644 --- a/Tests/Event/DomainEventTest.php +++ b/Tests/Event/DomainEventTest.php @@ -4,21 +4,19 @@ use Biig\Component\Domain\Event\DomainEvent; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\GenericEvent; class DomainEventTest extends TestCase { - public function testItIsInstanceOfSymfonyEvent() + public function testItIsInstanceOfGenericEvent() { $event = new DomainEvent(); - $this->assertInstanceOf(Event::class, $event); + $this->assertInstanceOf(GenericEvent::class, $event); } public function testItAcceptAnEventAsParameter() { $event = new DomainEvent(null, [], new GenericEvent()); - $this->assertInstanceOf(GenericEvent::class, $event->getOriginalEvent()); } @@ -30,4 +28,12 @@ public function testItReturnIfDelayedOrNot() $event->setDelayed(); $this->assertTrue($event->isDelayed()); } + + /** + * @expectedException \Biig\Component\Domain\Exception\InvalidArgumentException + */ + public function testItThrowsAnErrorIfOrignalEventIsNotAnEvent() + { + $event = new DomainEvent(null, [], 'foo'); + } } diff --git a/Tests/Model/Instantiator/DoctrineConfig/ClassMetadataFactoryTest.php b/Tests/Model/Instantiator/DoctrineConfig/ClassMetadataFactoryTest.php index 1017ab7..1be159e 100644 --- a/Tests/Model/Instantiator/DoctrineConfig/ClassMetadataFactoryTest.php +++ b/Tests/Model/Instantiator/DoctrineConfig/ClassMetadataFactoryTest.php @@ -5,6 +5,7 @@ require_once __DIR__ . '/../../../fixtures/FakeModel.php'; use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; use Biig\Component\Domain\Model\Instantiator\DoctrineConfig\ClassMetadata; use Biig\Component\Domain\Model\Instantiator\DoctrineConfig\ClassMetadataFactory; use Doctrine\ORM\EntityManager; @@ -46,7 +47,7 @@ public function testItAllowToRetrieveDomainModel() $config = Setup::createYAMLMetadataConfiguration(array(__DIR__ . '/../../../fixtures/config'), true); $config->setClassMetadataFactoryName(ClassMetadataFactory::class); - $dispatcher = $this->prophesize(DomainEventDispatcher::class); + $dispatcher = $this->prophesize(DomainEventDispatcherInterface::class); $dispatcher->dispatch(Argument::cetera())->shouldBeCalled(); $conn = [ diff --git a/Tests/PostPersistListener/DoctrinePostPersistListenerTest.php b/Tests/PostPersistListener/DoctrinePostPersistListenerTest.php index fd30039..9206c6d 100644 --- a/Tests/PostPersistListener/DoctrinePostPersistListenerTest.php +++ b/Tests/PostPersistListener/DoctrinePostPersistListenerTest.php @@ -5,6 +5,7 @@ require_once __DIR__ . '/../fixtures/FakeModel.php'; use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; use Biig\Component\Domain\PostPersistListener\DoctrinePostPersistListener; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Event\OnFlushEventArgs; @@ -18,7 +19,7 @@ public function testItCallPersistForEachFlushedModel() { $model = new \FakeModel(); - $dispatcher = $this->prophesize(DomainEventDispatcher::class); + $dispatcher = $this->prophesize(DomainEventDispatcherInterface::class); $dispatcher->persistModel($model)->shouldBeCalled(); $unitOfWork = $this->prophesize(UnitOfWork::class); diff --git a/Tests/Symfony/DependencyInjection/EntityManagerConfiguratorTest.php b/Tests/Symfony/DependencyInjection/EntityManagerConfiguratorTest.php index c7882c6..91015c3 100644 --- a/Tests/Symfony/DependencyInjection/EntityManagerConfiguratorTest.php +++ b/Tests/Symfony/DependencyInjection/EntityManagerConfiguratorTest.php @@ -14,13 +14,12 @@ class EntityManagerConfiguratorTest extends TestCase public function testItInsertsTheDispatcher() { $entityManager = $this->prophesize(EntityManager::class); - $dispatcher = $this->prophesize(DomainEventDispatcher::class)->reveal(); $originalConfigurator = $this->prophesize(ManagerConfigurator::class)->reveal(); $factory = new ClassMetadataFactory(); $entityManager->getMetadataFactory()->willReturn($factory); - $configurator = new EntityManagerConfigurator($originalConfigurator, $dispatcher); + $configurator = new EntityManagerConfigurator($originalConfigurator, new DomainEventDispatcher()); $configurator->configure($entityManager->reveal()); $ref = new \ReflectionObject($factory); diff --git a/Tests/Symfony/Serializer/DomainDenormalizerTest.php b/Tests/Symfony/Serializer/DomainDenormalizerTest.php index fdc0ec8..3a7a2ec 100644 --- a/Tests/Symfony/Serializer/DomainDenormalizerTest.php +++ b/Tests/Symfony/Serializer/DomainDenormalizerTest.php @@ -26,19 +26,19 @@ class DomainDenormalizerTest extends TestCase public function setUp() { $this->decorated = $this->prophesize(ObjectNormalizer::class); - $this->dispatcher = $this->prophesize(DomainEventDispatcher::class); + $this->dispatcher = new DomainEventDispatcher(); } public function testItIsAnInstanceOfDenormalize() { - $denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher->reveal()); + $denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher); $this->assertInstanceOf(DenormalizerInterface::class, $denormalizer); } public function testItDoesntSupportsDenormalization() { $this->decorated->supportsDenormalization(Argument::cetera())->willReturn(false); - $denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher->reveal()); + $denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher); $this->assertFalse($denormalizer->supportsDenormalization([], \stdClass::class, [])); $this->assertFalse($denormalizer->supportsDenormalization([], \FakeModel::class, [])); @@ -47,7 +47,7 @@ public function testItDoesntSupportsDenormalization() public function testItSupportsDenormalization() { $this->decorated->supportsDenormalization(Argument::cetera())->willReturn(true); - $denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher->reveal()); + $denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher); $this->assertTrue($denormalizer->supportsDenormalization([], \stdClass::class, [])); $this->assertTrue($denormalizer->supportsDenormalization([], \FakeModel::class, [])); @@ -58,9 +58,9 @@ public function testDenormalize() $fake = $this->prophesize(\FakeModel::class); $this->decorated->denormalize([], \FakeModel::class, null, [])->willReturn($fake)->shouldBeCalled(); - $fake->setDispatcher($this->dispatcher->reveal())->shouldBeCalled(); + $fake->setDispatcher($this->dispatcher)->shouldBeCalled(); - $denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher->reveal()); + $denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher); $denormalizer->denormalize([], \FakeModel::class, null, []); } } diff --git a/Tests/fixtures/FakeModel.php b/Tests/fixtures/FakeModel.php index ab0fdb6..e94c5f5 100644 --- a/Tests/fixtures/FakeModel.php +++ b/Tests/fixtures/FakeModel.php @@ -58,7 +58,7 @@ public function setFoo($foo) */ public function doAction() { - $this->dispatch('previous_action', new \Biig\Component\Domain\Event\DomainEvent($this)); - $this->dispatch('action', new \Biig\Component\Domain\Event\DomainEvent($this)); + $this->dispatch(new \Biig\Component\Domain\Event\DomainEvent($this), 'previous_action'); + $this->dispatch(new \Biig\Component\Domain\Event\DomainEvent($this), 'action'); } } diff --git a/composer.json b/composer.json index 3a050a8..2f15f7d 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,8 @@ "license": "MIT", "require": { "php": ">=7.1", - "symfony/event-dispatcher": "~3.3|~4.0" + "symfony/event-dispatcher": "^4.3|^5.0", + "doctrine/orm": "^2.6.3" }, "authors": [ { @@ -14,10 +15,13 @@ ], "require-dev": { "phpunit/phpunit": "^6.4", - "doctrine/orm": "^2.5", - "symfony/symfony": "~3.3|~4.0", + "doctrine/orm": "^2.6.3", "friendsofphp/php-cs-fixer": "^2.14", - "doctrine/doctrine-bundle": "^1.8" + "doctrine/doctrine-bundle": "^1.8", + "symfony/symfony": "^4.3|^5.0" + }, + "conflict": { + "doctrine/orm": "<2.6.3" }, "autoload": { "psr-4": { diff --git a/src/Event/DomainEvent.php b/src/Event/DomainEvent.php index b7de021..da12112 100644 --- a/src/Event/DomainEvent.php +++ b/src/Event/DomainEvent.php @@ -2,13 +2,14 @@ namespace Biig\Component\Domain\Event; -use Symfony\Component\EventDispatcher\Event; +use Biig\Component\Domain\Exception\InvalidArgumentException; use Symfony\Component\EventDispatcher\GenericEvent; + class DomainEvent extends GenericEvent { /** - * @var Event + * @var \Symfony\Component\EventDispatcher\Event|\Symfony\Contracts\EventDispatcher\Event|null */ private $originalEvent; @@ -19,17 +20,26 @@ class DomainEvent extends GenericEvent */ private $delayed; - public function __construct($subject = null, $arguments = [], Event $originalEvent = null) + public function __construct($subject = null, $arguments = [], /* Event */ $originalEvent = null) { + // BC layer for Symfony 4.3 + if (!\is_null($originalEvent) && + !((class_exists(\Symfony\Component\EventDispatcher\Event::class) && $originalEvent instanceof \Symfony\Component\EventDispatcher\Event) + || (class_exists(\Symfony\Contracts\EventDispatcher\Event::class) && $originalEvent instanceof \Symfony\Contracts\EventDispatcher\Event) + ) + ) { + throw new InvalidArgumentException('The orignal event must be an instance of Symfony Events'); + } + parent::__construct($subject, $arguments); $this->originalEvent = $originalEvent; $this->delayed = false; } /** - * @return Event + * @return \Symfony\Component\EventDispatcher\Event|\Symfony\Contracts\EventDispatcher\Event|null */ - public function getOriginalEvent(): ?Event + public function getOriginalEvent() { return $this->originalEvent; } diff --git a/src/Event/DomainEventDispatcher.php b/src/Event/DomainEventDispatcher.php index 4059056..e1b915c 100644 --- a/src/Event/DomainEventDispatcher.php +++ b/src/Event/DomainEventDispatcher.php @@ -7,10 +7,10 @@ use Biig\Component\Domain\Rule\DomainRuleInterface; use Biig\Component\Domain\Rule\PostPersistDomainRuleInterface; use Biig\Component\Domain\Rule\RuleInterface; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcher; -class DomainEventDispatcher extends EventDispatcher +final class DomainEventDispatcher extends EventDispatcher implements DomainEventDispatcherInterface { /** * @var DelayedListener[] @@ -19,6 +19,7 @@ class DomainEventDispatcher extends EventDispatcher public function __construct() { + parent::__construct(); $this->delayedListeners = []; } @@ -79,14 +80,14 @@ public function addPostPersistDomainRuleInterface(PostPersistDomainRuleInterface } /** - * @param string $eventName * @param Event|null $event * * @return Event */ - public function dispatch($eventName, Event $event = null) + public function dispatch($event/*, string $eventName = null*/) { - $event = parent::dispatch($eventName, $event); + $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; + $event = parent::dispatch($event, $eventName); if ($event instanceof DomainEvent) { foreach ($this->delayedListeners as $listener) { @@ -104,6 +105,7 @@ public function dispatch($eventName, Event $event = null) */ public function persistModel(ModelInterface $model) { + foreach ($this->delayedListeners as $listener) { if ($listener->shouldOccur($model)) { $listener->process($model); diff --git a/src/Event/DomainEventDispatcherInterface.php b/src/Event/DomainEventDispatcherInterface.php new file mode 100644 index 0000000..bc8f673 --- /dev/null +++ b/src/Event/DomainEventDispatcherInterface.php @@ -0,0 +1,15 @@ +getRootNode(); - } else { - // BC for symfony/config < 4.2 - $rootNode = $treeBuilder->root('biig_domain'); - } - - $rootNode + $treeBuilder + ->getRootNode() ->children() ->booleanNode('override_doctrine_instantiator') ->defaultTrue() diff --git a/src/Integration/Symfony/DependencyInjection/EntityManagerConfigurator.php b/src/Integration/Symfony/DependencyInjection/EntityManagerConfigurator.php index dcbffd8..dd83bc7 100644 --- a/src/Integration/Symfony/DependencyInjection/EntityManagerConfigurator.php +++ b/src/Integration/Symfony/DependencyInjection/EntityManagerConfigurator.php @@ -2,7 +2,7 @@ namespace Biig\Component\Domain\Integration\Symfony\DependencyInjection; -use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; use Biig\Component\Domain\Model\Instantiator\DoctrineConfig\ClassMetadataFactory; use Doctrine\Bundle\DoctrineBundle\ManagerConfigurator; use Doctrine\ORM\EntityManager; @@ -18,11 +18,11 @@ class EntityManagerConfigurator private $originalConfigurator; /** - * @var DomainEventDispatcher + * @var DomainEventDispatcherInterface */ private $dispatcher; - public function __construct(ManagerConfigurator $configurator, DomainEventDispatcher $dispatcher) + public function __construct(ManagerConfigurator $configurator, DomainEventDispatcherInterface $dispatcher) { $this->originalConfigurator = $configurator; $this->dispatcher = $dispatcher; diff --git a/src/Integration/Symfony/Resources/config/services.yaml b/src/Integration/Symfony/Resources/config/services.yaml index c2cdf28..f95c0cf 100644 --- a/src/Integration/Symfony/Resources/config/services.yaml +++ b/src/Integration/Symfony/Resources/config/services.yaml @@ -3,6 +3,7 @@ services: class: Biig\Component\Domain\Event\DomainEventDispatcher Biig\Component\Domain\Event\DomainEventDispatcher: '@biig_domain.dispatcher' + Biig\Component\Domain\Event\DomainEventDispatcherInterface: '@Biig\Component\Domain\Event\DomainEventDispatcher' Biig\Component\Domain\Model\Instantiator\Instantiator: arguments: @@ -11,3 +12,4 @@ services: biig_domain.instantiator.default: alias: Biig\Component\Domain\Model\Instantiator\Instantiator public: true + diff --git a/src/Integration/Symfony/Serializer/ApiPlatformDomainDenormalizer.php b/src/Integration/Symfony/Serializer/ApiPlatformDomainDenormalizer.php deleted file mode 100644 index 076b5c8..0000000 --- a/src/Integration/Symfony/Serializer/ApiPlatformDomainDenormalizer.php +++ /dev/null @@ -1,10 +0,0 @@ -decorated->denormalize($data, $class, $format, $context); - $domain->setDispatcher($this->dispatcher); - - return $domain; - } -} diff --git a/src/Model/DomainModelTrait.php b/src/Model/DomainModelTrait.php index 5e22133..6e175fe 100644 --- a/src/Model/DomainModelTrait.php +++ b/src/Model/DomainModelTrait.php @@ -3,12 +3,12 @@ namespace Biig\Component\Domain\Model; use Biig\Component\Domain\Event\DomainEvent; -use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; trait DomainModelTrait { /** - * @var DomainEventDispatcher + * @var DomainEventDispatcherInterface */ private $dispatcher; @@ -21,25 +21,33 @@ trait DomainModelTrait */ private $eventStack = []; - public function setDispatcher(DomainEventDispatcher $dispatcher) + public function setDispatcher(DomainEventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; if (!empty($this->eventStack)) { while ($event = array_pop($this->eventStack)) { - $this->dispatcher->dispatch($event['name'], $event['event']); + if (isset($event['name'])) { + $this->dispatcher->dispatch($event['event'], $event['name']); + } else { + $this->dispatcher->dispatch($event['event']); + } } } } - protected function dispatch(string $name, DomainEvent $event) + protected function dispatch(DomainEvent $event, string $name = null) { if (null === $this->dispatcher) { - $this->eventStack[] = ['name' => $name, 'event' => $event]; + $eventToStack['event'] = $event; + if (!\is_null($name)) { + $eventToStack['name'] = $name; + } + $this->eventStack[] = $eventToStack; return; } - $this->dispatcher->dispatch($name, $event); + $this->dispatcher->dispatch($event, $name); } } diff --git a/src/Model/Instantiator/DoctrineConfig/ClassMetadataFactory.php b/src/Model/Instantiator/DoctrineConfig/ClassMetadataFactory.php index d43e717..2477c46 100644 --- a/src/Model/Instantiator/DoctrineConfig/ClassMetadataFactory.php +++ b/src/Model/Instantiator/DoctrineConfig/ClassMetadataFactory.php @@ -2,7 +2,7 @@ namespace Biig\Component\Domain\Model\Instantiator\DoctrineConfig; -use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; use Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface; use Doctrine\Common\Persistence\Mapping\ReflectionService; use Doctrine\ORM\EntityManagerInterface; @@ -11,7 +11,7 @@ final class ClassMetadataFactory extends BaseClassMetadataFactory { /** - * @var DomainEventDispatcher + * @var DomainEventDispatcherInterface */ private $dispatcher; @@ -29,9 +29,9 @@ public function newClassMetadataInstance($className) } /** - * @param DomainEventDispatcher $dispatcher + * @param DomainEventDispatcherInterface $dispatcher */ - public function setDispatcher(DomainEventDispatcher $dispatcher) + public function setDispatcher(DomainEventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; } diff --git a/src/Model/Instantiator/DoctrineConfig/Instantiator.php b/src/Model/Instantiator/DoctrineConfig/Instantiator.php index 61eb8ca..a343f1e 100644 --- a/src/Model/Instantiator/DoctrineConfig/Instantiator.php +++ b/src/Model/Instantiator/DoctrineConfig/Instantiator.php @@ -2,7 +2,7 @@ namespace Biig\Component\Domain\Model\Instantiator\DoctrineConfig; -use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; use Biig\Component\Domain\Model\Instantiator\Instantiator as BaseInstantiator; use Doctrine\Instantiator\InstantiatorInterface; @@ -11,7 +11,7 @@ */ class Instantiator extends BaseInstantiator implements InstantiatorInterface { - public function __construct(DomainEventDispatcher $dispatcher) + public function __construct(DomainEventDispatcherInterface $dispatcher) { parent::__construct($dispatcher); } diff --git a/src/Model/Instantiator/Instantiator.php b/src/Model/Instantiator/Instantiator.php index c3cf94e..c705ddd 100644 --- a/src/Model/Instantiator/Instantiator.php +++ b/src/Model/Instantiator/Instantiator.php @@ -2,7 +2,7 @@ namespace Biig\Component\Domain\Model\Instantiator; -use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; use Biig\Component\Domain\Model\ModelInterface; /** @@ -14,11 +14,11 @@ class Instantiator implements DomainModelInstantiatorInterface { /** - * @var DomainEventDispatcher + * @var DomainEventDispatcherInterface */ private $dispatcher; - public function __construct(DomainEventDispatcher $dispatcher) + public function __construct(DomainEventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; } diff --git a/src/Model/ModelInterface.php b/src/Model/ModelInterface.php index 36a28a7..dc06ff0 100644 --- a/src/Model/ModelInterface.php +++ b/src/Model/ModelInterface.php @@ -2,9 +2,9 @@ namespace Biig\Component\Domain\Model; -use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; interface ModelInterface { - public function setDispatcher(DomainEventDispatcher $dispatcher); + public function setDispatcher(DomainEventDispatcherInterface $dispatcher); } diff --git a/src/PostPersistListener/AbstractBridgeListener.php b/src/PostPersistListener/AbstractBridgeListener.php index dbb0cb3..01d85ad 100644 --- a/src/PostPersistListener/AbstractBridgeListener.php +++ b/src/PostPersistListener/AbstractBridgeListener.php @@ -2,7 +2,7 @@ namespace Biig\Component\Domain\PostPersistListener; -use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; /** * The job of the children of this class is to take a persist event @@ -11,11 +11,11 @@ abstract class AbstractBridgeListener { /** - * @var DomainEventDispatcher + * @var DomainEventDispatcherInterface */ private $dispatcher; - public function __construct(DomainEventDispatcher $dispatcher) + public function __construct(DomainEventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; } diff --git a/src/PostPersistListener/DoctrinePostPersistListener.php b/src/PostPersistListener/DoctrinePostPersistListener.php index dac5f46..6a90723 100644 --- a/src/PostPersistListener/DoctrinePostPersistListener.php +++ b/src/PostPersistListener/DoctrinePostPersistListener.php @@ -2,7 +2,8 @@ namespace Biig\Component\Domain\PostPersistListener; -use Biig\Component\Domain\Event\DomainEventDispatcher; +use Biig\Component\Domain\Event\DomainEventDispatcherInterface; +use Biig\Component\Domain\Model\DomainModel; use Biig\Component\Domain\Model\ModelInterface; use Doctrine\Common\EventSubscriber; use Doctrine\ORM\Event\OnFlushEventArgs; @@ -21,9 +22,9 @@ class DoctrinePostPersistListener extends AbstractBridgeListener implements Even private $modelsStageForFlush; /** - * @param DomainEventDispatcher $dispatcher + * @param DomainEventDispatcherInterface $dispatcher */ - public function __construct(DomainEventDispatcher $dispatcher) + public function __construct(DomainEventDispatcherInterface $dispatcher) { parent::__construct($dispatcher); $this->modelsStageForFlush = [];