Newscoop\ArticlesBundle\Entity\EditorialComment::setUser PHP Method

setUser() public method

Sets the value of user.
public setUser ( User $user ) : self
$user Newscoop\Entity\User the user
return self
    public function setUser(User $user)
    {
        $this->user = $user;
        return $this;
    }

Usage Example

 /**
  * Create new editorial comment for Article
  *
  * @param string                   $commentContent
  * @param Article                  $article
  * @param User                     $user
  * @param EditorialComment\null    $parrentComment
  */
 public function create($commentContent, Article $article, User $user, $parrentComment = null)
 {
     $editorialComment = new EditorialComment();
     $editorialComment->setComment($commentContent);
     $editorialComment->setUser($user);
     $editorialComment->setArticle($article);
     if ($parrentComment) {
         $editorialComment->setParent($parrentComment);
     }
     $this->em->persist($editorialComment);
     $this->em->flush();
     return $editorialComment;
 }