Exemple #1
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);
 }
Exemple #2
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);
 }