Exemplo n.º 1
0
 /**
  * Adds a post top the User's authored Posts.
  *
  * Post Author needs to be updated manually.
  *
  * @param Post $addPost
  * @return User
  */
 public function addPost(Post $addPost)
 {
     if (!$this->getAuthoredPosts()->contains($addPost)) {
         $this->authoredPosts->add($addPost);
     }
     return $this;
 }
Exemplo n.º 2
0
 public function addPost(Post $post)
 {
     if ($post->getAuthor() !== $this) {
         throw new DomainException('Author is not allowed');
     }
     if ($this->hasPost($post)) {
         throw new DomainException('Post already added');
     }
     $this->posts->add($post);
 }
 /**
  * @param Post $post
  * @return $this
  */
 public function addPost(Post $post)
 {
     $this->posts->add($post);
     return $this;
 }