Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function locate($nameOfMessage)
 {
     if (!$this->handlers->containsKey($nameOfMessage)) {
         throw NotFoundException::handlerFor($nameOfMessage);
     }
     return $this->handlers->get($nameOfMessage);
 }
Exemplo n.º 2
0
 /**
  * @param PropertyInterface $property
  */
 public function add(Property $property)
 {
     if ($this->properties->containsKey($property->name())) {
         throw new \LogicException('There already is a property with name ' . $property->name());
     }
     $this->properties->set($property->name(), $property);
 }
Exemplo n.º 3
0
 /**
  * @return Version
  */
 public function loadApplicationVersion()
 {
     if (!$this->store->containsKey(self::APPLICATION_VERSION_KEY)) {
         return Version::fromString('0.0.0');
     }
     return $this->store->get(self::APPLICATION_VERSION_KEY);
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function remove($aggregateType, IdInterface $aggregateId, Version $aggregateVersion, Version $applicationVersion)
 {
     $applicationKey = $this->getApplicationKey($applicationVersion);
     if (!$this->store->containsKey($applicationKey)) {
         return;
     }
     /** @var ArrayHashMap $applicationCollection */
     $applicationCollection = $this->store->get($applicationKey);
     $aggregateKey = $this->getAggregateKey($aggregateType, $aggregateVersion);
     if (!$applicationCollection->containsKey($aggregateKey)) {
         return;
     }
     /** @var ArrayHashMap $aggregateCollection */
     $aggregateCollection = $applicationCollection->get($aggregateKey);
     $aggregateCollection->removeAt($aggregateId->toNative());
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function removeAll($streamName, Version $aggregateVersion, Version $applicationVersion)
 {
     $applicationKey = $this->getApplicationKey($applicationVersion);
     if (!$this->store->containsKey($applicationKey)) {
         throw new \RuntimeException(sprintf('The application %s not found in the event store.', $applicationKey));
     }
     /** @var ArrayHashMap $applicationCollection */
     $applicationCollection = $this->store->get($applicationKey);
     $streamKey = $this->getStreamKey($streamName, $aggregateVersion);
     $applicationCollection->removeAt($streamKey);
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function removeListener($eventName, callable $listener)
 {
     if (!$this->listeners->containsKey($eventName)) {
         return;
     }
     /** @var SortedArrayHashMap $sortedListeners */
     $sortedListeners = $this->listeners->get($eventName);
     /** @var ArrayList $listeners */
     foreach ($sortedListeners as $priority => $listeners) {
         foreach ($listeners as $registered) {
             /** @var DelegateListener $registered */
             if ($registered->equals($listener)) {
                 $listeners->remove($registered);
             }
         }
         if ($listeners->count() == 0) {
             $sortedListeners->removeAt($priority);
         }
     }
     if ($sortedListeners->count() == 0) {
         $this->listeners->removeAt($eventName);
     }
 }