/** * Add a User * * @author Jeremie Samson <*****@*****.**> * * @param User $user * @param Post $post */ protected function onSuccess(User $user, Post $post) { $user->addPost($post); $this->em->flush(); }
/** * Set author * * @param \UserBundle\Entity\User $author * @return Post */ public function setAuthor(\UserBundle\Entity\User $author = null) { $this->author = $author; if (null !== $author) { $this->setAuthorName($author->getUsername()); $author->addPost($this); } return $this; }