From f81b18400d5272c179a6faadbdc938375dfc8c5b Mon Sep 17 00:00:00 2001 From: Alexander Miertsch Date: Sun, 26 Jul 2015 17:21:17 +0200 Subject: [PATCH 1/8] Psr-4 support + composer deps update --- composer.json | 15 +++++---------- src/{Prooph/EventStore => }/Adapter/Adapter.php | 0 .../Adapter/Exception/AdapterException.php | 0 .../Adapter/Exception/ConfigurationException.php | 0 .../Exception/InvalidArgumentException.php | 0 .../Adapter/Feature/CanHandleTransaction.php | 0 .../EventStore => }/Adapter/InMemoryAdapter.php | 0 .../Aggregate/AggregateRepository.php | 0 .../Aggregate/AggregateTranslator.php | 0 .../EventStore => }/Aggregate/AggregateType.php | 0 .../Aggregate/AggregateTypeProvider.php | 0 .../Aggregate/DefaultAggregateTranslator.php | 0 .../AggregateTranslationFailedException.php | 0 .../Exception/AggregateTypeException.php | 0 .../Configuration/Configuration.php | 0 .../Exception/ConfigurationException.php | 0 src/{Prooph/EventStore => }/EventStore.php | 0 .../Exception/EventStoreException.php | 0 .../Exception/InvalidArgumentException.php | 0 .../Exception/RuntimeException.php | 0 .../Exception/StreamNotFoundException.php | 0 src/{Prooph/EventStore => }/Feature/Feature.php | 0 .../EventStore => }/Feature/ZF2FeatureManager.php | 0 .../PersistenceEvent/PostCommitEvent.php | 0 .../PersistenceEvent/PreCommitEvent.php | 0 .../Stream/AggregateStreamStrategy.php | 0 .../Stream/AggregateTypeStreamStrategy.php | 0 .../Stream/DomainEventMetadataWriter.php | 0 .../Stream/SingleStreamStrategy.php | 0 src/{Prooph/EventStore => }/Stream/Stream.php | 0 src/{Prooph/EventStore => }/Stream/StreamName.php | 0 .../EventStore => }/Stream/StreamStrategy.php | 0 .../Aggregate/AggregateRepositoryTest.php | 0 .../EventStoreTest => }/EventStoreTest.php | 0 .../Feature/FeatureManagerTest.php | 0 .../Mock/EventLoggerFeature.php | 0 .../{Prooph/EventStoreTest => }/Mock/Product.php | 0 .../EventStoreTest => }/Mock/TestDomainEvent.php | 0 tests/{Prooph/EventStoreTest => }/Mock/User.php | 0 .../EventStoreTest => }/Mock/UserCreated.php | 0 .../EventStoreTest => }/Mock/UsernameChanged.php | 0 .../Stream/AggregateStreamStrategyTest.php | 0 .../Stream/AggregateTypeStreamStrategyTest.php | 0 .../Stream/SingleStreamStrategyTest.php | 0 tests/{Prooph/EventStoreTest => }/TestCase.php | 0 45 files changed, 5 insertions(+), 10 deletions(-) rename src/{Prooph/EventStore => }/Adapter/Adapter.php (100%) rename src/{Prooph/EventStore => }/Adapter/Exception/AdapterException.php (100%) rename src/{Prooph/EventStore => }/Adapter/Exception/ConfigurationException.php (100%) rename src/{Prooph/EventStore => }/Adapter/Exception/InvalidArgumentException.php (100%) rename src/{Prooph/EventStore => }/Adapter/Feature/CanHandleTransaction.php (100%) rename src/{Prooph/EventStore => }/Adapter/InMemoryAdapter.php (100%) rename src/{Prooph/EventStore => }/Aggregate/AggregateRepository.php (100%) rename src/{Prooph/EventStore => }/Aggregate/AggregateTranslator.php (100%) rename src/{Prooph/EventStore => }/Aggregate/AggregateType.php (100%) rename src/{Prooph/EventStore => }/Aggregate/AggregateTypeProvider.php (100%) rename src/{Prooph/EventStore => }/Aggregate/DefaultAggregateTranslator.php (100%) rename src/{Prooph/EventStore => }/Aggregate/Exception/AggregateTranslationFailedException.php (100%) rename src/{Prooph/EventStore => }/Aggregate/Exception/AggregateTypeException.php (100%) rename src/{Prooph/EventStore => }/Configuration/Configuration.php (100%) rename src/{Prooph/EventStore => }/Configuration/Exception/ConfigurationException.php (100%) rename src/{Prooph/EventStore => }/EventStore.php (100%) rename src/{Prooph/EventStore => }/Exception/EventStoreException.php (100%) rename src/{Prooph/EventStore => }/Exception/InvalidArgumentException.php (100%) rename src/{Prooph/EventStore => }/Exception/RuntimeException.php (100%) rename src/{Prooph/EventStore => }/Exception/StreamNotFoundException.php (100%) rename src/{Prooph/EventStore => }/Feature/Feature.php (100%) rename src/{Prooph/EventStore => }/Feature/ZF2FeatureManager.php (100%) rename src/{Prooph/EventStore => }/PersistenceEvent/PostCommitEvent.php (100%) rename src/{Prooph/EventStore => }/PersistenceEvent/PreCommitEvent.php (100%) rename src/{Prooph/EventStore => }/Stream/AggregateStreamStrategy.php (100%) rename src/{Prooph/EventStore => }/Stream/AggregateTypeStreamStrategy.php (100%) rename src/{Prooph/EventStore => }/Stream/DomainEventMetadataWriter.php (100%) rename src/{Prooph/EventStore => }/Stream/SingleStreamStrategy.php (100%) rename src/{Prooph/EventStore => }/Stream/Stream.php (100%) rename src/{Prooph/EventStore => }/Stream/StreamName.php (100%) rename src/{Prooph/EventStore => }/Stream/StreamStrategy.php (100%) rename tests/{Prooph/EventStoreTest => }/Aggregate/AggregateRepositoryTest.php (100%) rename tests/{Prooph/EventStoreTest => }/EventStoreTest.php (100%) rename tests/{Prooph/EventStoreTest => }/Feature/FeatureManagerTest.php (100%) rename tests/{Prooph/EventStoreTest => }/Mock/EventLoggerFeature.php (100%) rename tests/{Prooph/EventStoreTest => }/Mock/Product.php (100%) rename tests/{Prooph/EventStoreTest => }/Mock/TestDomainEvent.php (100%) rename tests/{Prooph/EventStoreTest => }/Mock/User.php (100%) rename tests/{Prooph/EventStoreTest => }/Mock/UserCreated.php (100%) rename tests/{Prooph/EventStoreTest => }/Mock/UsernameChanged.php (100%) rename tests/{Prooph/EventStoreTest => }/Stream/AggregateStreamStrategyTest.php (100%) rename tests/{Prooph/EventStoreTest => }/Stream/AggregateTypeStreamStrategyTest.php (100%) rename tests/{Prooph/EventStoreTest => }/Stream/SingleStreamStrategyTest.php (100%) rename tests/{Prooph/EventStoreTest => }/TestCase.php (100%) diff --git a/composer.json b/composer.json index dfc8457c..9bc04e36 100644 --- a/composer.json +++ b/composer.json @@ -25,29 +25,24 @@ "php": ">=5.5", "ramsey/uuid" : "~2.8", "beberlei/assert": "~2.3", - "prooph/common" : "~2.0" + "prooph/common" : "~3.1" }, "require-dev": { - "phpunit/phpunit": "3.7.*", + "phpunit/phpunit": "~4.7", "satooshi/php-coveralls": "dev-master" }, "suggest" : { "prooph/event-sourcing" : "Basic functionality for event sourced aggregates", - "prooph/service-bus" : "Enterprise Service Bus adapter to connect EventStore with messaging systems" + "prooph/service-bus" : "Message bus facade to connect the event store with messaging systems" }, "autoload": { - "psr-0": { + "psr-4": { "Prooph\\EventStore\\": "src/" } }, "autoload-dev": { - "psr-0": { + "psr-4": { "Prooph\\EventStoreTest\\": "tests/" } - }, - "extra": { - "branch-alias": { - "dev-master": "0.5-dev" - } } } diff --git a/src/Prooph/EventStore/Adapter/Adapter.php b/src/Adapter/Adapter.php similarity index 100% rename from src/Prooph/EventStore/Adapter/Adapter.php rename to src/Adapter/Adapter.php diff --git a/src/Prooph/EventStore/Adapter/Exception/AdapterException.php b/src/Adapter/Exception/AdapterException.php similarity index 100% rename from src/Prooph/EventStore/Adapter/Exception/AdapterException.php rename to src/Adapter/Exception/AdapterException.php diff --git a/src/Prooph/EventStore/Adapter/Exception/ConfigurationException.php b/src/Adapter/Exception/ConfigurationException.php similarity index 100% rename from src/Prooph/EventStore/Adapter/Exception/ConfigurationException.php rename to src/Adapter/Exception/ConfigurationException.php diff --git a/src/Prooph/EventStore/Adapter/Exception/InvalidArgumentException.php b/src/Adapter/Exception/InvalidArgumentException.php similarity index 100% rename from src/Prooph/EventStore/Adapter/Exception/InvalidArgumentException.php rename to src/Adapter/Exception/InvalidArgumentException.php diff --git a/src/Prooph/EventStore/Adapter/Feature/CanHandleTransaction.php b/src/Adapter/Feature/CanHandleTransaction.php similarity index 100% rename from src/Prooph/EventStore/Adapter/Feature/CanHandleTransaction.php rename to src/Adapter/Feature/CanHandleTransaction.php diff --git a/src/Prooph/EventStore/Adapter/InMemoryAdapter.php b/src/Adapter/InMemoryAdapter.php similarity index 100% rename from src/Prooph/EventStore/Adapter/InMemoryAdapter.php rename to src/Adapter/InMemoryAdapter.php diff --git a/src/Prooph/EventStore/Aggregate/AggregateRepository.php b/src/Aggregate/AggregateRepository.php similarity index 100% rename from src/Prooph/EventStore/Aggregate/AggregateRepository.php rename to src/Aggregate/AggregateRepository.php diff --git a/src/Prooph/EventStore/Aggregate/AggregateTranslator.php b/src/Aggregate/AggregateTranslator.php similarity index 100% rename from src/Prooph/EventStore/Aggregate/AggregateTranslator.php rename to src/Aggregate/AggregateTranslator.php diff --git a/src/Prooph/EventStore/Aggregate/AggregateType.php b/src/Aggregate/AggregateType.php similarity index 100% rename from src/Prooph/EventStore/Aggregate/AggregateType.php rename to src/Aggregate/AggregateType.php diff --git a/src/Prooph/EventStore/Aggregate/AggregateTypeProvider.php b/src/Aggregate/AggregateTypeProvider.php similarity index 100% rename from src/Prooph/EventStore/Aggregate/AggregateTypeProvider.php rename to src/Aggregate/AggregateTypeProvider.php diff --git a/src/Prooph/EventStore/Aggregate/DefaultAggregateTranslator.php b/src/Aggregate/DefaultAggregateTranslator.php similarity index 100% rename from src/Prooph/EventStore/Aggregate/DefaultAggregateTranslator.php rename to src/Aggregate/DefaultAggregateTranslator.php diff --git a/src/Prooph/EventStore/Aggregate/Exception/AggregateTranslationFailedException.php b/src/Aggregate/Exception/AggregateTranslationFailedException.php similarity index 100% rename from src/Prooph/EventStore/Aggregate/Exception/AggregateTranslationFailedException.php rename to src/Aggregate/Exception/AggregateTranslationFailedException.php diff --git a/src/Prooph/EventStore/Aggregate/Exception/AggregateTypeException.php b/src/Aggregate/Exception/AggregateTypeException.php similarity index 100% rename from src/Prooph/EventStore/Aggregate/Exception/AggregateTypeException.php rename to src/Aggregate/Exception/AggregateTypeException.php diff --git a/src/Prooph/EventStore/Configuration/Configuration.php b/src/Configuration/Configuration.php similarity index 100% rename from src/Prooph/EventStore/Configuration/Configuration.php rename to src/Configuration/Configuration.php diff --git a/src/Prooph/EventStore/Configuration/Exception/ConfigurationException.php b/src/Configuration/Exception/ConfigurationException.php similarity index 100% rename from src/Prooph/EventStore/Configuration/Exception/ConfigurationException.php rename to src/Configuration/Exception/ConfigurationException.php diff --git a/src/Prooph/EventStore/EventStore.php b/src/EventStore.php similarity index 100% rename from src/Prooph/EventStore/EventStore.php rename to src/EventStore.php diff --git a/src/Prooph/EventStore/Exception/EventStoreException.php b/src/Exception/EventStoreException.php similarity index 100% rename from src/Prooph/EventStore/Exception/EventStoreException.php rename to src/Exception/EventStoreException.php diff --git a/src/Prooph/EventStore/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php similarity index 100% rename from src/Prooph/EventStore/Exception/InvalidArgumentException.php rename to src/Exception/InvalidArgumentException.php diff --git a/src/Prooph/EventStore/Exception/RuntimeException.php b/src/Exception/RuntimeException.php similarity index 100% rename from src/Prooph/EventStore/Exception/RuntimeException.php rename to src/Exception/RuntimeException.php diff --git a/src/Prooph/EventStore/Exception/StreamNotFoundException.php b/src/Exception/StreamNotFoundException.php similarity index 100% rename from src/Prooph/EventStore/Exception/StreamNotFoundException.php rename to src/Exception/StreamNotFoundException.php diff --git a/src/Prooph/EventStore/Feature/Feature.php b/src/Feature/Feature.php similarity index 100% rename from src/Prooph/EventStore/Feature/Feature.php rename to src/Feature/Feature.php diff --git a/src/Prooph/EventStore/Feature/ZF2FeatureManager.php b/src/Feature/ZF2FeatureManager.php similarity index 100% rename from src/Prooph/EventStore/Feature/ZF2FeatureManager.php rename to src/Feature/ZF2FeatureManager.php diff --git a/src/Prooph/EventStore/PersistenceEvent/PostCommitEvent.php b/src/PersistenceEvent/PostCommitEvent.php similarity index 100% rename from src/Prooph/EventStore/PersistenceEvent/PostCommitEvent.php rename to src/PersistenceEvent/PostCommitEvent.php diff --git a/src/Prooph/EventStore/PersistenceEvent/PreCommitEvent.php b/src/PersistenceEvent/PreCommitEvent.php similarity index 100% rename from src/Prooph/EventStore/PersistenceEvent/PreCommitEvent.php rename to src/PersistenceEvent/PreCommitEvent.php diff --git a/src/Prooph/EventStore/Stream/AggregateStreamStrategy.php b/src/Stream/AggregateStreamStrategy.php similarity index 100% rename from src/Prooph/EventStore/Stream/AggregateStreamStrategy.php rename to src/Stream/AggregateStreamStrategy.php diff --git a/src/Prooph/EventStore/Stream/AggregateTypeStreamStrategy.php b/src/Stream/AggregateTypeStreamStrategy.php similarity index 100% rename from src/Prooph/EventStore/Stream/AggregateTypeStreamStrategy.php rename to src/Stream/AggregateTypeStreamStrategy.php diff --git a/src/Prooph/EventStore/Stream/DomainEventMetadataWriter.php b/src/Stream/DomainEventMetadataWriter.php similarity index 100% rename from src/Prooph/EventStore/Stream/DomainEventMetadataWriter.php rename to src/Stream/DomainEventMetadataWriter.php diff --git a/src/Prooph/EventStore/Stream/SingleStreamStrategy.php b/src/Stream/SingleStreamStrategy.php similarity index 100% rename from src/Prooph/EventStore/Stream/SingleStreamStrategy.php rename to src/Stream/SingleStreamStrategy.php diff --git a/src/Prooph/EventStore/Stream/Stream.php b/src/Stream/Stream.php similarity index 100% rename from src/Prooph/EventStore/Stream/Stream.php rename to src/Stream/Stream.php diff --git a/src/Prooph/EventStore/Stream/StreamName.php b/src/Stream/StreamName.php similarity index 100% rename from src/Prooph/EventStore/Stream/StreamName.php rename to src/Stream/StreamName.php diff --git a/src/Prooph/EventStore/Stream/StreamStrategy.php b/src/Stream/StreamStrategy.php similarity index 100% rename from src/Prooph/EventStore/Stream/StreamStrategy.php rename to src/Stream/StreamStrategy.php diff --git a/tests/Prooph/EventStoreTest/Aggregate/AggregateRepositoryTest.php b/tests/Aggregate/AggregateRepositoryTest.php similarity index 100% rename from tests/Prooph/EventStoreTest/Aggregate/AggregateRepositoryTest.php rename to tests/Aggregate/AggregateRepositoryTest.php diff --git a/tests/Prooph/EventStoreTest/EventStoreTest.php b/tests/EventStoreTest.php similarity index 100% rename from tests/Prooph/EventStoreTest/EventStoreTest.php rename to tests/EventStoreTest.php diff --git a/tests/Prooph/EventStoreTest/Feature/FeatureManagerTest.php b/tests/Feature/FeatureManagerTest.php similarity index 100% rename from tests/Prooph/EventStoreTest/Feature/FeatureManagerTest.php rename to tests/Feature/FeatureManagerTest.php diff --git a/tests/Prooph/EventStoreTest/Mock/EventLoggerFeature.php b/tests/Mock/EventLoggerFeature.php similarity index 100% rename from tests/Prooph/EventStoreTest/Mock/EventLoggerFeature.php rename to tests/Mock/EventLoggerFeature.php diff --git a/tests/Prooph/EventStoreTest/Mock/Product.php b/tests/Mock/Product.php similarity index 100% rename from tests/Prooph/EventStoreTest/Mock/Product.php rename to tests/Mock/Product.php diff --git a/tests/Prooph/EventStoreTest/Mock/TestDomainEvent.php b/tests/Mock/TestDomainEvent.php similarity index 100% rename from tests/Prooph/EventStoreTest/Mock/TestDomainEvent.php rename to tests/Mock/TestDomainEvent.php diff --git a/tests/Prooph/EventStoreTest/Mock/User.php b/tests/Mock/User.php similarity index 100% rename from tests/Prooph/EventStoreTest/Mock/User.php rename to tests/Mock/User.php diff --git a/tests/Prooph/EventStoreTest/Mock/UserCreated.php b/tests/Mock/UserCreated.php similarity index 100% rename from tests/Prooph/EventStoreTest/Mock/UserCreated.php rename to tests/Mock/UserCreated.php diff --git a/tests/Prooph/EventStoreTest/Mock/UsernameChanged.php b/tests/Mock/UsernameChanged.php similarity index 100% rename from tests/Prooph/EventStoreTest/Mock/UsernameChanged.php rename to tests/Mock/UsernameChanged.php diff --git a/tests/Prooph/EventStoreTest/Stream/AggregateStreamStrategyTest.php b/tests/Stream/AggregateStreamStrategyTest.php similarity index 100% rename from tests/Prooph/EventStoreTest/Stream/AggregateStreamStrategyTest.php rename to tests/Stream/AggregateStreamStrategyTest.php diff --git a/tests/Prooph/EventStoreTest/Stream/AggregateTypeStreamStrategyTest.php b/tests/Stream/AggregateTypeStreamStrategyTest.php similarity index 100% rename from tests/Prooph/EventStoreTest/Stream/AggregateTypeStreamStrategyTest.php rename to tests/Stream/AggregateTypeStreamStrategyTest.php diff --git a/tests/Prooph/EventStoreTest/Stream/SingleStreamStrategyTest.php b/tests/Stream/SingleStreamStrategyTest.php similarity index 100% rename from tests/Prooph/EventStoreTest/Stream/SingleStreamStrategyTest.php rename to tests/Stream/SingleStreamStrategyTest.php diff --git a/tests/Prooph/EventStoreTest/TestCase.php b/tests/TestCase.php similarity index 100% rename from tests/Prooph/EventStoreTest/TestCase.php rename to tests/TestCase.php From 7df328f3caf8e0d07dbb145a516bae6ff759f4bd Mon Sep 17 00:00:00 2001 From: Alexander Miertsch Date: Sun, 26 Jul 2015 17:23:13 +0200 Subject: [PATCH 2/8] Update LICENSE --- LICENSE | 27 +++++++++++++++++++++++++++ LICENSE.txt | 27 --------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 LICENSE delete mode 100644 LICENSE.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..64ea5241 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014-2015, prooph software GmbH +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the prooph software GmbH nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index cea8ba73..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014, Alexander Miertsch kontakt@codeliner.ws -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of Alexander Miertsch nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From baa521dbddc1d97942d1f5c1933e0bdc971c2fdf Mon Sep 17 00:00:00 2001 From: Alexander Miertsch Date: Sun, 26 Jul 2015 17:53:20 +0200 Subject: [PATCH 3/8] Naming convention cleanup and update to prooph/common 3.x --- composer.json | 3 +- src/Aggregate/AggregateRepository.php | 77 +++++++++++--------- src/Aggregate/AggregateTranslator.php | 9 ++- src/Aggregate/AggregateTypeProvider.php | 4 +- src/Aggregate/DefaultAggregateTranslator.php | 20 ++--- src/Configuration/Configuration.php | 64 ++++++++-------- src/EventStore.php | 50 ++++++------- tests/EventStoreTest.php | 30 ++++---- tests/Mock/EventLoggerFeature.php | 2 +- 9 files changed, 130 insertions(+), 129 deletions(-) diff --git a/composer.json b/composer.json index 9bc04e36..fd1ec871 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "php": ">=5.5", "ramsey/uuid" : "~2.8", "beberlei/assert": "~2.3", - "prooph/common" : "~3.1" + "prooph/common" : "~3.1", + "container-interop/container-interop" : "~1.1" }, "require-dev": { "phpunit/phpunit": "~4.7", diff --git a/src/Aggregate/AggregateRepository.php b/src/Aggregate/AggregateRepository.php index 939691ab..6e4f2c22 100644 --- a/src/Aggregate/AggregateRepository.php +++ b/src/Aggregate/AggregateRepository.php @@ -63,7 +63,7 @@ public function __construct( ) { $this->eventStore = $eventStore; - $this->eventStore->getActionEventDispatcher()->attachListener('commit.pre', array($this, 'onPreCommit')); + $this->eventStore->getActionEventEmitter()->attachListener('commit.pre', $this); $this->aggregateTranslator = $aggregateTranslator; $this->streamStrategy = $streamStrategy; @@ -71,44 +71,67 @@ public function __construct( } /** - * @param object $anEventSourcedAggregateRoot + * Repository acts as listener on EventStore.commit.pre events + * In the listener method the repository checks its identity map for pending events + * and appends the events to the event stream. + */ + public function __invoke() + { + foreach ($this->identityMap as $eventSourcedAggregateRoot) { + + $pendingStreamEvents = $this->aggregateTranslator->extractPendingStreamEvents($eventSourcedAggregateRoot); + + if (count($pendingStreamEvents)) { + + $this->streamStrategy->appendEvents( + $this->aggregateType, + $this->aggregateTranslator->extractAggregateId($eventSourcedAggregateRoot), + $pendingStreamEvents, + $eventSourcedAggregateRoot + ); + } + } + } + + /** + * @param object $eventSourcedAggregateRoot * @throws Exception\AggregateTypeException */ - public function addAggregateRoot($anEventSourcedAggregateRoot) + public function addAggregateRoot($eventSourcedAggregateRoot) { - if (! is_object($anEventSourcedAggregateRoot)) { + if (! is_object($eventSourcedAggregateRoot)) { throw new AggregateTypeException( sprintf( 'Invalid aggregate given. Aggregates need to be of type object but type of %s given', - gettype($anEventSourcedAggregateRoot) + gettype($eventSourcedAggregateRoot) ) ); } - $aggregateId = $this->aggregateTranslator->extractAggregateId($anEventSourcedAggregateRoot); + $aggregateId = $this->aggregateTranslator->extractAggregateId($eventSourcedAggregateRoot); - $domainEvents = $this->aggregateTranslator->extractPendingStreamEvents($anEventSourcedAggregateRoot); + $domainEvents = $this->aggregateTranslator->extractPendingStreamEvents($eventSourcedAggregateRoot); - $this->streamStrategy->addEventsForNewAggregateRoot($this->aggregateType, $aggregateId, $domainEvents, $anEventSourcedAggregateRoot); + $this->streamStrategy->addEventsForNewAggregateRoot($this->aggregateType, $aggregateId, $domainEvents, $eventSourcedAggregateRoot); - $this->identityMap[$aggregateId] = $anEventSourcedAggregateRoot; + $this->identityMap[$aggregateId] = $eventSourcedAggregateRoot; } /** * Returns null if no stream events can be found for aggregate root otherwise the reconstituted aggregate root * - * @param string $anAggregateId + * @param string $aggregateId * @return null|object */ - public function getAggregateRoot($anAggregateId) + public function getAggregateRoot($aggregateId) { - Assertion::string($anAggregateId, 'AggregateId needs to be string'); + Assertion::string($aggregateId, 'AggregateId needs to be string'); - if (isset($this->identityMap[$anAggregateId])) { - return $this->identityMap[$anAggregateId]; + if (isset($this->identityMap[$aggregateId])) { + return $this->identityMap[$aggregateId]; } - $streamEvents = $this->streamStrategy->read($this->aggregateType, $anAggregateId); + $streamEvents = $this->streamStrategy->read($this->aggregateType, $aggregateId); if (count($streamEvents) === 0) { return null; @@ -116,32 +139,14 @@ public function getAggregateRoot($anAggregateId) $aggregateType = $this->streamStrategy->getAggregateRootType($this->aggregateType, $streamEvents); - $anEventSourcedAggregateRoot = $this->aggregateTranslator->reconstituteAggregateFromHistory( + $eventSourcedAggregateRoot = $this->aggregateTranslator->reconstituteAggregateFromHistory( $aggregateType, $streamEvents ); - $this->identityMap[$anAggregateId] = $anEventSourcedAggregateRoot; - - return $anEventSourcedAggregateRoot; - } - - public function onPreCommit() - { - foreach ($this->identityMap as $eventSourcedAggregateRoot) { - - $pendingStreamEvents = $this->aggregateTranslator->extractPendingStreamEvents($eventSourcedAggregateRoot); - - if (count($pendingStreamEvents)) { + $this->identityMap[$aggregateId] = $eventSourcedAggregateRoot; - $this->streamStrategy->appendEvents( - $this->aggregateType, - $this->aggregateTranslator->extractAggregateId($eventSourcedAggregateRoot), - $pendingStreamEvents, - $eventSourcedAggregateRoot - ); - } - } + return $eventSourcedAggregateRoot; } } \ No newline at end of file diff --git a/src/Aggregate/AggregateTranslator.php b/src/Aggregate/AggregateTranslator.php index 0b158ef1..48e579ad 100644 --- a/src/Aggregate/AggregateTranslator.php +++ b/src/Aggregate/AggregateTranslator.php @@ -10,6 +10,7 @@ */ namespace Prooph\EventStore\Aggregate; + use Prooph\Common\Messaging\DomainEvent; /** @@ -21,10 +22,10 @@ interface AggregateTranslator { /** - * @param object $anEventSourcedAggregateRoot + * @param object $eventSourcedAggregateRoot * @return string */ - public function extractAggregateId($anEventSourcedAggregateRoot); + public function extractAggregateId($eventSourcedAggregateRoot); /** * @param AggregateType $aggregateType @@ -34,9 +35,9 @@ public function extractAggregateId($anEventSourcedAggregateRoot); public function reconstituteAggregateFromHistory(AggregateType $aggregateType, array $historyEvents); /** - * @param object $anEventSourcedAggregateRoot + * @param object $eventSourcedAggregateRoot * @return DomainEvent[] */ - public function extractPendingStreamEvents($anEventSourcedAggregateRoot); + public function extractPendingStreamEvents($eventSourcedAggregateRoot); } \ No newline at end of file diff --git a/src/Aggregate/AggregateTypeProvider.php b/src/Aggregate/AggregateTypeProvider.php index 7253541f..e217ee43 100644 --- a/src/Aggregate/AggregateTypeProvider.php +++ b/src/Aggregate/AggregateTypeProvider.php @@ -12,9 +12,9 @@ namespace Prooph\EventStore\Aggregate; /** - * Interface AggregateTypeProviderInterface + * Interface AggregateTypeProvider * - * @package Prooph\EventStore\EventSourcing + * @package Prooph\EventStore\Aggregate * @author Alexander Miertsch */ interface AggregateTypeProvider diff --git a/src/Aggregate/DefaultAggregateTranslator.php b/src/Aggregate/DefaultAggregateTranslator.php index 53db75e8..8bf17cf4 100644 --- a/src/Aggregate/DefaultAggregateTranslator.php +++ b/src/Aggregate/DefaultAggregateTranslator.php @@ -23,22 +23,22 @@ class DefaultAggregateTranslator implements AggregateTranslator { /** - * @param object $anEventSourcedAggregateRoot + * @param object $eventSourcedAggregateRoot * @throws Exception\AggregateTranslationFailedException * @return string */ - public function extractAggregateId($anEventSourcedAggregateRoot) + public function extractAggregateId($eventSourcedAggregateRoot) { - if (! method_exists($anEventSourcedAggregateRoot, 'id')) { + if (! method_exists($eventSourcedAggregateRoot, 'id')) { throw new AggregateTranslationFailedException( sprintf( 'Required method id does not exist for aggregate %s', - get_class($anEventSourcedAggregateRoot) + get_class($eventSourcedAggregateRoot) ) ); } - return (string)$anEventSourcedAggregateRoot->id(); + return (string)$eventSourcedAggregateRoot->id(); } /** @@ -81,19 +81,19 @@ public function reconstituteAggregateFromHistory(AggregateType $aggregateType, a } /** - * @param object $anEventSourcedAggregateRoot + * @param object $eventSourcedAggregateRoot * @throws Exception\AggregateTranslationFailedException * @return DomainEvent[] */ - public function extractPendingStreamEvents($anEventSourcedAggregateRoot) + public function extractPendingStreamEvents($eventSourcedAggregateRoot) { - $refObj = new \ReflectionClass($anEventSourcedAggregateRoot); + $refObj = new \ReflectionClass($eventSourcedAggregateRoot); if (! $refObj->hasMethod('popRecordedEvents')) { throw new AggregateTranslationFailedException( sprintf( 'Can not extract pending events of aggregate %s. Class is missing a method with name popRecordedEvents!', - get_class($anEventSourcedAggregateRoot) + get_class($eventSourcedAggregateRoot) ) ); } @@ -102,7 +102,7 @@ public function extractPendingStreamEvents($anEventSourcedAggregateRoot) $popRecordedEventsMethod->setAccessible(true); - $recordedEvents = $popRecordedEventsMethod->invoke($anEventSourcedAggregateRoot); + $recordedEvents = $popRecordedEventsMethod->invoke($eventSourcedAggregateRoot); return $recordedEvents; } diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index 83bdc44b..c76db330 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -9,17 +9,13 @@ namespace Prooph\EventStore\Configuration; use Assert\Assertion; -use Prooph\Common\Event\ActionEventDispatcher; -use Prooph\Common\Event\ZF2\Zf2ActionEvent; -use Prooph\Common\Event\ZF2\Zf2ActionEventDispatcher; -use Prooph\Common\ServiceLocator\ServiceLocator; -use Prooph\Common\ServiceLocator\ZF2\Zf2ServiceManagerProxy; +use Interop\Container\ContainerInterface; +use Prooph\Common\Event\ActionEventEmitter; +use Prooph\Common\Event\ProophActionEventEmitter; use Prooph\EventStore\Adapter\Adapter; use Prooph\EventStore\Configuration\Exception\ConfigurationException; use Prooph\EventStore\EventStore; use Prooph\EventStore\Feature\Feature; -use Prooph\EventStore\Feature\ZF2FeatureManager; -use Zend\ServiceManager\Config; /** * Configuration @@ -39,14 +35,14 @@ class Configuration protected $adapter; /** - * @var ServiceLocator + * @var ContainerInterface */ protected $featureManager; /** - * @var ActionEventDispatcher + * @var ActionEventEmitter */ - protected $actionEventDispatcher; + protected $actionEventEmitter; /** * @var array @@ -63,9 +59,9 @@ public function __construct(array $config = null) } if (isset($config['feature_manager'])) { - Assertion::isArray($config['feature_manager'], "EventStore.Configuration.feature_manager must be an array"); + Assertion::isInstanceOf($config['feature_manager'], ContainerInterface::class); - $this->featureManager = new ZF2FeatureManager(new Config($config['feature_manager'])); + $this->featureManager = $config['feature_manager']; } if (isset($config['features'])) { @@ -73,6 +69,12 @@ public function __construct(array $config = null) $this->featureList = $config['features']; } + + if (isset($config['action_event_emitter'])) { + Assertion::isInstanceOf($config['action_event_emitter'], ActionEventEmitter::class); + + $this->actionEventEmitter = $config['action_event_emitter']; + } } /** @@ -81,8 +83,12 @@ public function __construct(array $config = null) */ public function setUpEventStoreEnvironment(EventStore $eventStore) { + if ($this->featureManager === null) { + return; + } + foreach ($this->featureList as $featureAlias) { - $feature = $this->getFeatureManager()->get($featureAlias); + $feature = $this->featureManager->get($featureAlias); if (! $feature instanceof Feature) { throw ConfigurationException::configurationError(sprintf('Feature %s does not implement the Feature interface', $featureAlias)); @@ -155,42 +161,30 @@ public function setAdapter(Adapter $adapter) } /** - * @return ServiceLocator - */ - public function getFeatureManager() - { - if (is_null($this->featureManager)) { - $this->featureManager = Zf2ServiceManagerProxy::proxy(new ZF2FeatureManager()); - } - - return $this->featureManager; - } - - /** - * @param ServiceLocator $featureManager + * @param ContainerInterface $featureManager */ - public function setFeatureManager(ServiceLocator $featureManager) + public function setFeatureManager(ContainerInterface $featureManager) { $this->featureManager = $featureManager; } /** - * @return ActionEventDispatcher + * @return ActionEventEmitter */ - public function getActionEventDispatcher() + public function getActionEventEmitter() { - if (is_null($this->actionEventDispatcher)) { - $this->actionEventDispatcher = new Zf2ActionEventDispatcher(); + if (is_null($this->actionEventEmitter)) { + $this->actionEventEmitter = new ProophActionEventEmitter(); } - return $this->actionEventDispatcher; + return $this->actionEventEmitter; } /** - * @param ActionEventDispatcher $actionEventDispatcher + * @param ActionEventEmitter $actionEventEmitter */ - public function setActionEventDispatcher(ActionEventDispatcher $actionEventDispatcher) + public function setActionEventEmitter(ActionEventEmitter $actionEventEmitter) { - $this->actionEventDispatcher = $actionEventDispatcher; + $this->actionEventEmitter = $actionEventEmitter; } } diff --git a/src/EventStore.php b/src/EventStore.php index fcc90767..eae56387 100644 --- a/src/EventStore.php +++ b/src/EventStore.php @@ -9,7 +9,7 @@ namespace Prooph\EventStore; use Assert\Assertion; -use Prooph\Common\Event\ActionEventDispatcher; +use Prooph\Common\Event\ActionEventEmitter; use Prooph\Common\Messaging\DomainEvent; use Prooph\EventStore\Adapter\Adapter; use Prooph\EventStore\Adapter\Feature\CanHandleTransaction; @@ -36,9 +36,9 @@ class EventStore protected $adapter; /** - * @var ActionEventDispatcher + * @var ActionEventEmitter */ - protected $actionEventDispatcher; + protected $actionEventEmitter; /** * @var DomainEvent[] @@ -58,7 +58,7 @@ class EventStore public function __construct(Configuration $config) { $this->adapter = $config->getAdapter(); - $this->actionEventDispatcher = $config->getActionEventDispatcher(); + $this->actionEventEmitter = $config->getActionEventEmitter(); $config->setUpEventStoreEnvironment($this); } @@ -90,9 +90,9 @@ public function create(Stream $stream) { $argv = array('stream' => $stream); - $event = $this->actionEventDispatcher->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv); + $event = $this->actionEventEmitter->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv); - $this->actionEventDispatcher->dispatch($event); + $this->actionEventEmitter->dispatch($event); if ($event->propagationIsStopped()) { return; @@ -110,7 +110,7 @@ public function create(Stream $stream) $event->setName(__FUNCTION__ . '.post'); - $this->actionEventDispatcher->dispatch($event); + $this->actionEventEmitter->dispatch($event); } /** @@ -127,9 +127,9 @@ public function appendTo(StreamName $streamName, array $streamEvents) $argv = array('streamName' => $streamName, 'streamEvents' => $streamEvents); - $event = $this->actionEventDispatcher->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv); + $event = $this->actionEventEmitter->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv); - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); if ($event->propagationIsStopped()) { return; @@ -148,7 +148,7 @@ public function appendTo(StreamName $streamName, array $streamEvents) $event->setName(__FUNCTION__, '.post'); - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); } /** @@ -161,9 +161,9 @@ public function load(StreamName $streamName, $minVersion = null) { $argv = array('streamName' => $streamName, 'minVersion' => $minVersion); - $event = $this->actionEventDispatcher->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv); + $event = $this->actionEventEmitter->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv); - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); if ($event->propagationIsStopped()) { @@ -200,7 +200,7 @@ public function load(StreamName $streamName, $minVersion = null) $event->setParam('stream', $stream); - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); if ($event->propagationIsStopped()) { throw new StreamNotFoundException( @@ -224,9 +224,9 @@ public function loadEventsByMetadataFrom(StreamName $streamName, array $metadata { $argv = array('streamName' => $streamName, 'metadata' => $metadata, 'minVersion' => $minVersion); - $event = $this->actionEventDispatcher->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv); + $event = $this->actionEventEmitter->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv); - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); if ($event->propagationIsStopped()) { return $event->getParam('streamEvents', array()); @@ -242,7 +242,7 @@ public function loadEventsByMetadataFrom(StreamName $streamName, array $metadata $event->setParam('streamEvents', $events); - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); if ($event->propagationIsStopped()) { return array(); @@ -264,13 +264,13 @@ public function beginTransaction() $this->transactionLevel++; - $event = $this->actionEventDispatcher->getNewActionEvent( + $event = $this->actionEventEmitter->getNewActionEvent( __FUNCTION__, $this, ['isNestedTransaction' => $this->transactionLevel > 1, 'transactionLevel' => $this->transactionLevel] ); - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); } /** @@ -291,7 +291,7 @@ public function commit() $event->setParam('isNestedTransaction', $this->transactionLevel > 1); $event->setParam('transactionLevel', $this->transactionLevel); - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); if ($event->propagationIsStopped()) { $this->rollback(); @@ -313,7 +313,7 @@ public function commit() $this->recordedEvents = []; - $this->getActionEventDispatcher()->dispatch($event); + $this->getActionEventEmitter()->dispatch($event); } /** @@ -333,18 +333,18 @@ public function rollback() $this->transactionLevel = 0; - $event = $this->actionEventDispatcher->getNewActionEvent(__FUNCTION__, $this); + $event = $this->actionEventEmitter->getNewActionEvent(__FUNCTION__, $this); - $this->actionEventDispatcher->dispatch($event); + $this->actionEventEmitter->dispatch($event); $this->recordedEvents = []; } /** - * @return ActionEventDispatcher + * @return ActionEventEmitter */ - public function getActionEventDispatcher() + public function getActionEventEmitter() { - return $this->actionEventDispatcher; + return $this->actionEventEmitter; } } diff --git a/tests/EventStoreTest.php b/tests/EventStoreTest.php index e8933965..34854686 100644 --- a/tests/EventStoreTest.php +++ b/tests/EventStoreTest.php @@ -37,7 +37,7 @@ public function it_creates_a_new_stream_and_records_the_stream_events() { $recordedEvents = array(); - $this->eventStore->getActionEventDispatcher()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { foreach ($event->getRecordedEvents() as $recordedEvent) { $recordedEvents[] = $recordedEvent; } @@ -67,7 +67,7 @@ function it_allows_nested_transactions_but_triggers_commit_post_event_only_once( { $postCommitEventCount = 0; - $this->eventStore->getActionEventDispatcher()->attachListener('commit.post', function (PostCommitEvent $event) use (&$postCommitEventCount) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$postCommitEventCount) { $postCommitEventCount++; }); @@ -93,7 +93,7 @@ function it_triggers_commit_pre_event_for_nested_transaction_too() { $preCommitEventCount = 0; - $this->eventStore->getActionEventDispatcher()->attachListener('commit.pre', function (PreCommitEvent $event) use (&$preCommitEventCount) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.pre', function (PreCommitEvent $event) use (&$preCommitEventCount) { $preCommitEventCount++; }); @@ -123,7 +123,7 @@ function it_adds_information_about_transaction_level_to_commit_pre_event() $transactionFlagOfMainTransaction = null; $triggerCount = 0; - $this->eventStore->getActionEventDispatcher()->attachListener( + $this->eventStore->getActionEventEmitter()->attachListener( 'commit.pre', function (PreCommitEvent $event) use ( &$transactionLevelOfNestedTransaction, &$transactionFlagOfNestedTransaction, &$triggerCount, @@ -170,7 +170,7 @@ function it_adds_information_about_transaction_level_to_begin_transaction_event_ $transactionFlagOfMainTransaction = null; $triggerCount = 0; - $this->eventStore->getActionEventDispatcher()->attachListener( + $this->eventStore->getActionEventEmitter()->attachListener( 'beginTransaction', function (ActionEvent $event) use ( &$transactionLevelOfNestedTransaction, &$transactionFlagOfNestedTransaction, &$triggerCount, @@ -213,13 +213,13 @@ public function it_stops_stream_creation_when_listener_stops_propagation() { $recordedEvents = array(); - $this->eventStore->getActionEventDispatcher()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { foreach ($event->getRecordedEvents() as $recordedEvent) { $recordedEvents[] = $recordedEvent; } }); - $this->eventStore->getActionEventDispatcher()->attachListener('create.pre', function (ActionEvent $event) { + $this->eventStore->getActionEventEmitter()->attachListener('create.pre', function (ActionEvent $event) { $event->stopPropagation(true); }); @@ -251,7 +251,7 @@ public function it_appends_events_to_stream_and_records_them() { $recordedEvents = array(); - $this->eventStore->getActionEventDispatcher()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { foreach ($event->getRecordedEvents() as $recordedEvent) { $recordedEvents[] = $recordedEvent; } @@ -284,7 +284,7 @@ public function it_does_not_append_events_when_listener_stops_propagation() { $recordedEvents = array(); - $this->eventStore->getActionEventDispatcher()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { foreach ($event->getRecordedEvents() as $recordedEvent) { $recordedEvents[] = $recordedEvent; } @@ -296,7 +296,7 @@ public function it_does_not_append_events_when_listener_stops_propagation() $this->eventStore->commit(); - $this->eventStore->getActionEventDispatcher()->attachListener('appendTo.pre', function (Event $event) { + $this->eventStore->getActionEventEmitter()->attachListener('appendTo.pre', function (Event $event) { $event->stopPropagation(true); }); @@ -439,7 +439,7 @@ public function it_returns_empty_array_when_listener_stops_loading_events_and_do $this->eventStore->commit(); - $this->eventStore->getActionEventDispatcher()->attachListener('loadEventsByMetadataFrom.pre', function (ActionEvent $event) { + $this->eventStore->getActionEventEmitter()->attachListener('loadEventsByMetadataFrom.pre', function (ActionEvent $event) { $event->stopPropagation(true); }); @@ -474,7 +474,7 @@ public function it_returns_listener_events_when_listener_stops_loading_events_an $this->eventStore->commit(); - $this->eventStore->getActionEventDispatcher()->attachListener('loadEventsByMetadataFrom.pre', function (ActionEvent $event) { + $this->eventStore->getActionEventEmitter()->attachListener('loadEventsByMetadataFrom.pre', function (ActionEvent $event) { $streamEventWithMetadataButOtherUuid = UsernameChanged::with( array('new_name' => 'John Doe'), 1 @@ -506,7 +506,7 @@ public function it_breaks_loading_a_stream_when_listener_stops_propagation_but_d $this->eventStore->commit(); - $this->eventStore->getActionEventDispatcher()->attachListener('load.pre', function (ActionEvent $event) { + $this->eventStore->getActionEventEmitter()->attachListener('load.pre', function (ActionEvent $event) { $event->stopPropagation(true); }); @@ -528,7 +528,7 @@ public function it_breaks_loading_a_stream_when_listener_stops_propagation_and_p $this->eventStore->commit(); - $this->eventStore->getActionEventDispatcher()->attachListener('load.pre', function (Event $event) { + $this->eventStore->getActionEventEmitter()->attachListener('load.pre', function (Event $event) { $event->setParam('stream', new Stream(new StreamName('EmptyStream'), array())); $event->stopPropagation(true); }); @@ -551,7 +551,7 @@ public function it_uses_stream_provided_by_listener_when_listener_stops_propagat $this->eventStore->commit(); - $this->eventStore->getActionEventDispatcher()->attachListener('load.pre', function (ActionEvent $event) { + $this->eventStore->getActionEventEmitter()->attachListener('load.pre', function (ActionEvent $event) { $event->setParam('stream', new Stream(new StreamName('user'), array())); $event->stopPropagation(true); }); diff --git a/tests/Mock/EventLoggerFeature.php b/tests/Mock/EventLoggerFeature.php index 663a7717..3a10b1e7 100644 --- a/tests/Mock/EventLoggerFeature.php +++ b/tests/Mock/EventLoggerFeature.php @@ -35,7 +35,7 @@ class EventLoggerFeature implements Feature */ public function setUp(EventStore $eventStore) { - $eventStore->getActionEventDispatcher()->attachListener('commit.post', array($this, "onPostCommit")); + $eventStore->getActionEventEmitter()->attachListener('commit.post', array($this, "onPostCommit")); } /** From 7944ce3e5bfa675cb594efd85f148a13ca581c0e Mon Sep 17 00:00:00 2001 From: Alexander Miertsch Date: Sun, 26 Jul 2015 18:02:50 +0200 Subject: [PATCH 4/8] Get rid of specific event implemenations - Closes #47 --- src/EventStore.php | 10 ++---- src/PersistenceEvent/PostCommitEvent.php | 42 ------------------------ src/PersistenceEvent/PreCommitEvent.php | 33 ------------------- 3 files changed, 3 insertions(+), 82 deletions(-) delete mode 100644 src/PersistenceEvent/PostCommitEvent.php delete mode 100644 src/PersistenceEvent/PreCommitEvent.php diff --git a/src/EventStore.php b/src/EventStore.php index eae56387..52582a8b 100644 --- a/src/EventStore.php +++ b/src/EventStore.php @@ -16,8 +16,6 @@ use Prooph\EventStore\Configuration\Configuration; use Prooph\EventStore\Exception\StreamNotFoundException; use Prooph\EventStore\Exception\RuntimeException; -use Prooph\EventStore\PersistenceEvent\PostCommitEvent; -use Prooph\EventStore\PersistenceEvent\PreCommitEvent; use Prooph\EventStore\Stream\Stream; use Prooph\EventStore\Stream\StreamName; @@ -277,7 +275,7 @@ public function beginTransaction() * Commit transaction * * @triggers commit.pre On every commit call. If a listener stops propagation, the ES performs a rollback - * @triggers commit.post Once after all started transactions are committed. Event includes all recorded StreamEvents. + * @triggers commit.post Once after all started transactions are committed. Event includes all "recordedEvents". * Perfect to attach a domain event dispatcher */ public function commit() @@ -286,7 +284,7 @@ public function commit() throw new RuntimeException('Cannot commit transaction. EventStore has no active transaction'); } - $event = new PreCommitEvent(__FUNCTION__ . '.pre', $this); + $event = $this->getActionEventEmitter()->getNewActionEvent(__FUNCTION__ . '.pre', $this); $event->setParam('isNestedTransaction', $this->transactionLevel > 1); $event->setParam('transactionLevel', $this->transactionLevel); @@ -307,9 +305,7 @@ public function commit() $this->adapter->commit(); } - $argv = array('recordedEvents' => $this->recordedEvents); - - $event = new PostCommitEvent(__FUNCTION__ . '.post', $this, $argv); + $event = $this->getActionEventEmitter()->getNewActionEvent(__FUNCTION__ . '.post', $this, ['recordedEvents' => $this->recordedEvents]); $this->recordedEvents = []; diff --git a/src/PersistenceEvent/PostCommitEvent.php b/src/PersistenceEvent/PostCommitEvent.php deleted file mode 100644 index 5dc54814..00000000 --- a/src/PersistenceEvent/PostCommitEvent.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * Date: 20.04.14 - 20:53 - */ - -namespace Prooph\EventStore\PersistenceEvent; - -use Prooph\Common\Event\ZF2\Zf2ActionEvent; -use Prooph\Common\Messaging\DomainEvent; -use Prooph\EventStore\EventStore; - -/** - * Class PostCommitEvent - * - * @package Prooph\EventStore\PersistenceEvent - * @author Alexander Miertsch - */ -class PostCommitEvent extends Zf2ActionEvent -{ - /** - * @return EventStore - */ - public function getEventStore() - { - return $this->getTarget(); - } - - /** - * @return DomainEvent[] - */ - public function getRecordedEvents() - { - return $this->getParam('recordedEvents', array()); - } -} - \ No newline at end of file diff --git a/src/PersistenceEvent/PreCommitEvent.php b/src/PersistenceEvent/PreCommitEvent.php deleted file mode 100644 index e2627010..00000000 --- a/src/PersistenceEvent/PreCommitEvent.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * Date: 20.04.14 - 20:51 - */ - -namespace Prooph\EventStore\PersistenceEvent; - -use Prooph\Common\Event\ZF2\Zf2ActionEvent; -use Prooph\EventStore\EventStore; - -/** - * Class PreCommitEvent - * - * @package Prooph\EventStore\PersistenceEvent - * @author Alexander Miertsch - */ -class PreCommitEvent extends Zf2ActionEvent -{ - /** - * @return EventStore - */ - public function getEventStore() - { - return $this->getTarget(); - } -} - \ No newline at end of file From dccf8ed6f80707f5623a2e9abdfe5ef0ba83e273 Mon Sep 17 00:00:00 2001 From: Alexander Miertsch Date: Sun, 26 Jul 2015 18:23:38 +0200 Subject: [PATCH 5/8] Fix tests --- composer.json | 3 +- src/Stream/AggregateTypeStreamStrategy.php | 4 +-- src/Stream/SingleStreamStrategy.php | 8 ++--- tests/EventStoreTest.php | 42 ++++++++++------------ tests/Feature/FeatureManagerTest.php | 17 +++++---- tests/Mock/EventLoggerFeature.php | 8 ++--- tests/Mock/TestDomainEvent.php | 11 ++++-- tests/phpunit.xml.dist | 2 +- 8 files changed, 51 insertions(+), 44 deletions(-) diff --git a/composer.json b/composer.json index fd1ec871..db8afc68 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ }, "require-dev": { "phpunit/phpunit": "~4.7", - "satooshi/php-coveralls": "dev-master" + "satooshi/php-coveralls": "dev-master", + "zendframework/zend-servicemanager": "~2.6" }, "suggest" : { "prooph/event-sourcing" : "Basic functionality for event sourced aggregates", diff --git a/src/Stream/AggregateTypeStreamStrategy.php b/src/Stream/AggregateTypeStreamStrategy.php index 07481a44..10ed5e55 100644 --- a/src/Stream/AggregateTypeStreamStrategy.php +++ b/src/Stream/AggregateTypeStreamStrategy.php @@ -68,7 +68,7 @@ public function addEventsForNewAggregateRoot(AggregateType $repositoryAggregateT Assertion::string($aggregateId, 'AggregateId needs to be string'); foreach ( $streamEvents as &$streamEvent) { - DomainEventMetadataWriter::setMetadataKey($streamEvent, 'aggregate_id', $aggregateId); + $streamEvent = $streamEvent->withAddedMetadata('aggregate_id', $aggregateId); } $this->eventStore->appendTo($streamName, $streamEvents); @@ -95,7 +95,7 @@ public function appendEvents(AggregateType $repositoryAggregateType, $aggregateI Assertion::string($aggregateId, 'AggregateId needs to be string'); foreach ($streamEvents as &$streamEvent) { - DomainEventMetadataWriter::setMetadataKey($streamEvent, 'aggregate_id', $aggregateId); + $streamEvent = $streamEvent->withAddedMetadata('aggregate_id', $aggregateId); } $this->eventStore->appendTo($streamName, $streamEvents); diff --git a/src/Stream/SingleStreamStrategy.php b/src/Stream/SingleStreamStrategy.php index 71e47b49..69daa52d 100644 --- a/src/Stream/SingleStreamStrategy.php +++ b/src/Stream/SingleStreamStrategy.php @@ -72,8 +72,8 @@ public function addEventsForNewAggregateRoot(AggregateType $repositoryAggregateT Assertion::string($aggregateId, 'AggregateId needs to be string'); foreach ( $streamEvents as &$streamEvent) { - DomainEventMetadataWriter::setMetadataKey($streamEvent, 'aggregate_type', get_class($aggregateRoot)); - DomainEventMetadataWriter::setMetadataKey($streamEvent, 'aggregate_id', $aggregateId); + $streamEvent = $streamEvent->withAddedMetadata('aggregate_id', $aggregateId); + $streamEvent = $streamEvent->withAddedMetadata('aggregate_type', get_class($aggregateRoot)); } $this->eventStore->appendTo($this->streamName, $streamEvents); @@ -91,8 +91,8 @@ public function appendEvents(AggregateType $repositoryAggregateType, $aggregateI Assertion::string($aggregateId, 'AggregateId needs to be string'); foreach ( $streamEvents as &$streamEvent) { - DomainEventMetadataWriter::setMetadataKey($streamEvent, 'aggregate_type', get_class($aggregateRoot)); - DomainEventMetadataWriter::setMetadataKey($streamEvent, 'aggregate_id', $aggregateId); + $streamEvent = $streamEvent->withAddedMetadata('aggregate_id', $aggregateId); + $streamEvent = $streamEvent->withAddedMetadata('aggregate_type', get_class($aggregateRoot)); } $this->eventStore->appendTo($this->streamName, $streamEvents); diff --git a/tests/EventStoreTest.php b/tests/EventStoreTest.php index 34854686..d2022bb6 100644 --- a/tests/EventStoreTest.php +++ b/tests/EventStoreTest.php @@ -12,15 +12,11 @@ namespace Prooph\EventStoreTest; use Prooph\Common\Event\ActionEvent; -use Prooph\EventStore\PersistenceEvent\PostCommitEvent; -use Prooph\EventStore\PersistenceEvent\PreCommitEvent; -use Prooph\EventStore\Stream\DomainEventMetadataWriter; use Prooph\EventStore\Stream\Stream; use Prooph\EventStore\Stream\StreamName; use Prooph\EventStoreTest\Mock\TestDomainEvent; use Prooph\EventStoreTest\Mock\UserCreated; use Prooph\EventStoreTest\Mock\UsernameChanged; -use Zend\EventManager\Event; /** * Class EventStoreTest @@ -37,8 +33,8 @@ public function it_creates_a_new_stream_and_records_the_stream_events() { $recordedEvents = array(); - $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { - foreach ($event->getRecordedEvents() as $recordedEvent) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (ActionEvent $event) use (&$recordedEvents) { + foreach ($event->getParam('recordedEvents', []) as $recordedEvent) { $recordedEvents[] = $recordedEvent; } }); @@ -67,7 +63,7 @@ function it_allows_nested_transactions_but_triggers_commit_post_event_only_once( { $postCommitEventCount = 0; - $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$postCommitEventCount) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (ActionEvent $event) use (&$postCommitEventCount) { $postCommitEventCount++; }); @@ -93,7 +89,7 @@ function it_triggers_commit_pre_event_for_nested_transaction_too() { $preCommitEventCount = 0; - $this->eventStore->getActionEventEmitter()->attachListener('commit.pre', function (PreCommitEvent $event) use (&$preCommitEventCount) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.pre', function (ActionEvent $event) use (&$preCommitEventCount) { $preCommitEventCount++; }); @@ -125,7 +121,7 @@ function it_adds_information_about_transaction_level_to_commit_pre_event() $this->eventStore->getActionEventEmitter()->attachListener( 'commit.pre', - function (PreCommitEvent $event) use ( + function (ActionEvent $event) use ( &$transactionLevelOfNestedTransaction, &$transactionFlagOfNestedTransaction, &$triggerCount, &$transactionLevelOfMainTransaction, &$transactionFlagOfMainTransaction ) { @@ -213,8 +209,8 @@ public function it_stops_stream_creation_when_listener_stops_propagation() { $recordedEvents = array(); - $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { - foreach ($event->getRecordedEvents() as $recordedEvent) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (ActionEvent $event) use (&$recordedEvents) { + foreach ($event->getParam('recordedEvents', []) as $recordedEvent) { $recordedEvents[] = $recordedEvent; } }); @@ -251,8 +247,8 @@ public function it_appends_events_to_stream_and_records_them() { $recordedEvents = array(); - $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { - foreach ($event->getRecordedEvents() as $recordedEvent) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (ActionEvent $event) use (&$recordedEvents) { + foreach ($event->getParam('recordedEvents', []) as $recordedEvent) { $recordedEvents[] = $recordedEvent; } }); @@ -284,8 +280,8 @@ public function it_does_not_append_events_when_listener_stops_propagation() { $recordedEvents = array(); - $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (PostCommitEvent $event) use (&$recordedEvents) { - foreach ($event->getRecordedEvents() as $recordedEvent) { + $this->eventStore->getActionEventEmitter()->attachListener('commit.post', function (ActionEvent $event) use (&$recordedEvents) { + foreach ($event->getParam('recordedEvents', []) as $recordedEvent) { $recordedEvents[] = $recordedEvent; } }); @@ -296,7 +292,7 @@ public function it_does_not_append_events_when_listener_stops_propagation() $this->eventStore->commit(); - $this->eventStore->getActionEventEmitter()->attachListener('appendTo.pre', function (Event $event) { + $this->eventStore->getActionEventEmitter()->attachListener('appendTo.pre', function (ActionEvent $event) { $event->stopPropagation(true); }); @@ -350,7 +346,7 @@ public function it_loads_events_by_matching_metadata() 2 ); - DomainEventMetadataWriter::setMetadataKey($streamEventWithMetadata, 'snapshot', true); + $streamEventWithMetadata = $streamEventWithMetadata->withAddedMetadata('snapshot', true); $this->eventStore->beginTransaction(); @@ -383,14 +379,14 @@ public function it_loads_events_by_min_version() 2 ); - DomainEventMetadataWriter::setMetadataKey($streamEventVersion2, 'snapshot', true); + $streamEventVersion2 = $streamEventVersion2->withAddedMetadata('snapshot', true); $streamEventVersion3 = UsernameChanged::with( array('new_name' => 'John Doe'), 3 ); - DomainEventMetadataWriter::setMetadataKey($streamEventVersion3, 'snapshot', false); + $streamEventVersion3 = $streamEventVersion3->withAddedMetadata('snapshot', false); $this->eventStore->beginTransaction(); @@ -431,7 +427,7 @@ public function it_returns_empty_array_when_listener_stops_loading_events_and_do 2 ); - DomainEventMetadataWriter::setMetadataKey($streamEventWithMetadata, 'snapshot', true); + $streamEventWithMetadata = $streamEventWithMetadata->withAddedMetadata('snapshot', true); $this->eventStore->beginTransaction(); @@ -466,7 +462,7 @@ public function it_returns_listener_events_when_listener_stops_loading_events_an 2 ); - DomainEventMetadataWriter::setMetadataKey($streamEventWithMetadata, 'snapshot', true); + $streamEventWithMetadata = $streamEventWithMetadata->withAddedMetadata('snapshot', true); $this->eventStore->beginTransaction(); @@ -480,7 +476,7 @@ public function it_returns_listener_events_when_listener_stops_loading_events_an 1 ); - DomainEventMetadataWriter::setMetadataKey($streamEventWithMetadataButOtherUuid, 'snapshot', true); + $streamEventWithMetadataButOtherUuid = $streamEventWithMetadataButOtherUuid->withAddedMetadata('snapshot', true); $event->setParam('streamEvents', array($streamEventWithMetadataButOtherUuid)); $event->stopPropagation(true); @@ -528,7 +524,7 @@ public function it_breaks_loading_a_stream_when_listener_stops_propagation_and_p $this->eventStore->commit(); - $this->eventStore->getActionEventEmitter()->attachListener('load.pre', function (Event $event) { + $this->eventStore->getActionEventEmitter()->attachListener('load.pre', function (ActionEvent $event) { $event->setParam('stream', new Stream(new StreamName('EmptyStream'), array())); $event->stopPropagation(true); }); diff --git a/tests/Feature/FeatureManagerTest.php b/tests/Feature/FeatureManagerTest.php index 6632b7d8..0bd15e6a 100644 --- a/tests/Feature/FeatureManagerTest.php +++ b/tests/Feature/FeatureManagerTest.php @@ -17,8 +17,11 @@ use Prooph\EventStore\Configuration\Configuration; use Prooph\EventStore\EventStore; use Prooph\EventStore\Stream\AggregateStreamStrategy; +use Prooph\EventStoreTest\Mock\EventLoggerFeature; use Prooph\EventStoreTest\Mock\User; use Prooph\EventStoreTest\TestCase; +use Zend\ServiceManager\Config; +use Zend\ServiceManager\ServiceManager; /** * Class FeatureManagerTest @@ -33,15 +36,17 @@ class FeatureManagerTest extends TestCase */ public function an_invokable_feature_is_loaded_by_feature_manager_and_attached_to_event_store_by_configuration() { + $featureManager = new ServiceManager(new Config([ + "invokables" => [ + "eventlogger" => EventLoggerFeature::class, + ] + ])); + $config = array( "adapter" => array( "type" => "Prooph\EventStore\Adapter\InMemoryAdapter", ), - "feature_manager" => array( - "invokables" => array( - "eventlogger" => "Prooph\EventStoreTest\Mock\EventLoggerFeature" - ) - ), + "feature_manager" => $featureManager, "features" => array( "eventlogger", ) @@ -66,7 +71,7 @@ public function an_invokable_feature_is_loaded_by_feature_manager_and_attached_t $eventStore->commit(); - $loggedStreamEvents = $esConfig->getFeatureManager()->get("eventlogger")->getLoggedStreamEvents(); + $loggedStreamEvents = $featureManager->get("eventlogger")->getLoggedStreamEvents(); $this->assertEquals(1, count($loggedStreamEvents)); } diff --git a/tests/Mock/EventLoggerFeature.php b/tests/Mock/EventLoggerFeature.php index 3a10b1e7..ca53e44d 100644 --- a/tests/Mock/EventLoggerFeature.php +++ b/tests/Mock/EventLoggerFeature.php @@ -11,10 +11,10 @@ namespace Prooph\EventStoreTest\Mock; +use Prooph\Common\Event\ActionEvent; use Prooph\Common\Messaging\DomainEvent; use Prooph\EventStore\EventStore; use Prooph\EventStore\Feature\Feature; -use Prooph\EventStore\PersistenceEvent\PostCommitEvent; /** * Class EventLoggerFeature @@ -39,11 +39,11 @@ public function setUp(EventStore $eventStore) } /** - * @param PostCommitEvent $e + * @param ActionEvent $e */ - public function onPostCommit(PostCommitEvent $e) + public function onPostCommit(ActionEvent $e) { - $this->loggedStreamEvents = $e->getRecordedEvents(); + $this->loggedStreamEvents = $e->getParam('recordedEvents', []); } /** diff --git a/tests/Mock/TestDomainEvent.php b/tests/Mock/TestDomainEvent.php index b57524e2..a9d7e5e0 100644 --- a/tests/Mock/TestDomainEvent.php +++ b/tests/Mock/TestDomainEvent.php @@ -12,7 +12,8 @@ namespace Prooph\EventStoreTest\Mock; use Prooph\Common\Messaging\DomainEvent; -use Rhumsaa\Uuid\Uuid; +use Prooph\Common\Messaging\PayloadConstructable; +use Prooph\Common\Messaging\PayloadTrait; /** * Class DomainEvent @@ -20,8 +21,10 @@ * @package Prooph\EventStoreTest\Mock * @author Alexander Miertsch */ -class TestDomainEvent extends DomainEvent +class TestDomainEvent extends DomainEvent implements PayloadConstructable { + use PayloadTrait; + /** * @param array $payload * @param int $version @@ -29,7 +32,9 @@ class TestDomainEvent extends DomainEvent */ public static function with(array $payload, $version) { - return new static(get_called_class(), $payload, $version); + $event = new static($payload); + + return $event->withVersion($version); } } \ No newline at end of file diff --git a/tests/phpunit.xml.dist b/tests/phpunit.xml.dist index d650b6e4..d8014e6b 100644 --- a/tests/phpunit.xml.dist +++ b/tests/phpunit.xml.dist @@ -3,7 +3,7 @@ - ./Prooph/EventStoreTest + . \ No newline at end of file From ada1b6ff6a7a627f973999b93710d89541d56881 Mon Sep 17 00:00:00 2001 From: Alexander Miertsch Date: Sun, 26 Jul 2015 18:25:05 +0200 Subject: [PATCH 6/8] Remove ZF2FeatureManager --- src/Feature/ZF2FeatureManager.php | 50 ------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/Feature/ZF2FeatureManager.php diff --git a/src/Feature/ZF2FeatureManager.php b/src/Feature/ZF2FeatureManager.php deleted file mode 100644 index 58a5cb50..00000000 --- a/src/Feature/ZF2FeatureManager.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * Date: 20.04.14 - 23:56 - */ - -namespace Prooph\EventStore\Feature; - -use Prooph\Common\ServiceLocator\ServiceLocator; -use Prooph\EventStore\Exception\RuntimeException; -use Zend\ServiceManager\AbstractPluginManager; -use Zend\ServiceManager\Exception; - -/** - * Class ZF2FeatureManager - * - * @method Feature get($name) Get Feature by name or alias - * - * @package Prooph\EventStore\Feature - * @author Alexander Miertsch - */ -class ZF2FeatureManager extends AbstractPluginManager -{ - /** - * Validate the plugin - * - * Checks that the plugin loaded is a Feature - * of FilterInterface. - * - * @param mixed $plugin - * @return void - * @throws \Prooph\EventStore\Exception\RuntimeException if invalid - */ - public function validatePlugin($plugin) - { - if (! $plugin instanceof Feature) { - throw new RuntimeException(sprintf( - 'Feature must be instance of Prooph\EventStore\Feature\FeatureInterface,' - . 'instance of type %s given', - ((is_object($plugin)? get_class($plugin) : gettype($plugin))) - )); - } - } -} - \ No newline at end of file From 8cf8c92b9b3797571d8a5641959396bcb0014047 Mon Sep 17 00:00:00 2001 From: Alexander Miertsch Date: Sun, 26 Jul 2015 18:26:04 +0200 Subject: [PATCH 7/8] Remove DomainEventMetadataWriter --- src/Stream/DomainEventMetadataWriter.php | 32 ------------------------ 1 file changed, 32 deletions(-) delete mode 100644 src/Stream/DomainEventMetadataWriter.php diff --git a/src/Stream/DomainEventMetadataWriter.php b/src/Stream/DomainEventMetadataWriter.php deleted file mode 100644 index 297ace5f..00000000 --- a/src/Stream/DomainEventMetadataWriter.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @internal is used internally to add metadata to a DomainEvent - */ -final class DomainEventMetadataWriter extends DomainEvent -{ - /** - * @param DomainEvent $domainEvent - * @param string $key - * @param mixed $value - */ - public static function setMetadataKey(DomainEvent $domainEvent, $key, $value) - { - $domainEvent->metadata[$key] = $value; - } -} \ No newline at end of file From 180a9ab95235d0ccab81299748df71a70d6de40e Mon Sep 17 00:00:00 2001 From: Alexander Miertsch Date: Sun, 26 Jul 2015 18:27:51 +0200 Subject: [PATCH 8/8] New line between ns and use --- src/Stream/StreamName.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Stream/StreamName.php b/src/Stream/StreamName.php index 7c4b350e..76ba9856 100644 --- a/src/Stream/StreamName.php +++ b/src/Stream/StreamName.php @@ -10,6 +10,7 @@ */ namespace Prooph\EventStore\Stream; + use Assert\Assertion; /**