/** * @param RetractPost $command */ public function handle(RetractPost $command) { $draft = $this->postRepository->byId($command->postId); $draft->retract(); $this->postRepository->save($draft); }
/** * @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))); }
/** * @param PublishDraft $command */ public function handle(PublishDraft $command) { $draft = $this->postRepository->byId($command->postId); $draft->publish($command->postDateTime); $this->postRepository->save($draft); }