コード例 #1
0
 public function create(User $user, $title, $url, $tag)
 {
     if ($errors = $this->getErrors($title, $url, $tag)) {
         throw new ServiceException($errors);
     }
     $post = new Post();
     $post->setUser($user);
     $post->setTitle($title);
     $post->setUrl($url);
     $post->setTag($this->formatTag($tag));
     $post->setUpvoteTotal(0);
     $post->setCreatedAt(new \DateTime());
     return $this->repository->create($post);
 }