Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  *
  * @return ReadModelInterface|Collection
  */
 public function dispatchNow(MessageInterface $query)
 {
     if (!$query instanceof QueryInterface) {
         throw new InvalidArgumentException(sprintf('Query "%s" should implement \\Borobudur\\Cqrs\\Message\\QueryInterface', get_class($query)));
     }
     $results = parent::dispatchNow($query);
     if (null === $results) {
         return null;
     }
     return $results;
 }
Exemplo n.º 2
0
 /**
  * Dispatch command immediately.
  *
  * @param MessageInterface $command
  *
  * @return mixed
  * @throws Exception
  */
 public function dispatchNow(MessageInterface $command)
 {
     $this->beginTransaction();
     try {
         $result = parent::dispatchNow($command);
         $this->commit();
         return $result;
     } catch (Exception $e) {
         $this->rollback();
         throw $e;
     }
 }
Exemplo n.º 3
0
 private function getBus()
 {
     $bus = new Bus();
     $bus->register('\\Borobudur\\Bus\\Test\\Message', '\\Borobudur\\Bus\\Test\\MessageHandler');
     return $bus;
 }