Ejemplo n.º 1
0
 public function execute(Command $command, Responder $responder)
 {
     $comment = Comment::create($command->getPostId(), $command->getAuthor(), $command->getContent());
     try {
         $this->eventBus->dispatch($comment->getEvents());
         $this->eventStorage->add($comment);
     } catch (\Exception $e) {
         $responder->commentAddingFailed($e);
     }
     $responder->commentAddedSuccessfully($comment);
 }
Ejemplo n.º 2
0
 public function execute(Command $command, Responder $responder)
 {
     $post = Post::create($command->getTitle(), $command->getContent());
     try {
         $this->eventBus->dispatch($post->getEvents());
         $this->eventStorage->add($post);
     } catch (\Exception $e) {
         $responder->postPublishingFailed($e);
     }
     $responder->postPublishedSuccessfully($post);
 }
Ejemplo n.º 3
0
 public function execute(Command $command, Responder $responder)
 {
     $postAggregateHistory = new PostAggregateHistory($command->getPostId(), $this->eventStorage);
     $post = Post::reconstituteFrom($postAggregateHistory);
     $post->update($command->getTitle(), $command->getContent());
     try {
         $this->eventBus->dispatch($post->getEvents());
         $this->eventStorage->add($post);
     } catch (\Exception $e) {
         $responder->postUpdatingFailed($e);
     }
     $responder->postUpdatedSuccessfully($post);
 }