Пример #1
0
 /**
  * @param RetractPost $command
  */
 public function handle(RetractPost $command)
 {
     $draft = $this->postRepository->byId($command->postId);
     $draft->retract();
     $this->postRepository->save($draft);
 }
Пример #2
0
 /**
  * @param AddDraft $command
  * @throws InvalidArgumentException
  */
 public function handle(AddDraft $command)
 {
     $this->postRepository->save(Post::draft(new PostTitle($command->title), new PostIntroduction($command->introduction), new PostContent($command->content)));
 }
Пример #3
0
 /**
  * @param PublishDraft $command
  */
 public function handle(PublishDraft $command)
 {
     $draft = $this->postRepository->byId($command->postId);
     $draft->publish($command->postDateTime);
     $this->postRepository->save($draft);
 }