/**
  * Determine whether or not a comment form is visible on a page
  *
  * @param Content $content
  * @param User\UserInterface $user
  *
  * @return bool
  */
 public function isVisible(Content $content, User\UserInterface $user)
 {
     try {
         $this->_validator->validate($content);
     } catch (Exception\InvalidContentException $e) {
         return false;
     }
     if ($this->commentsDisabled($content)) {
         return false;
     }
     return $this->userAllowed($content, $user);
 }
 /**
  * Method for creating an instance of Comment using data taken from the comment form
  *
  * @param int $pageID
  * @param array $data
  * @param Content $content
  *
  * @return Comment
  */
 public function buildFromForm($pageID, array $data, Content $content)
 {
     $this->_validateData($data);
     $this->_contentValidator->validate($content);
     $comment = new Comment();
     $comment->setPageID($pageID);
     $comment->setName($data[self::NAME]);
     $comment->setEmail($data[self::EMAIL]);
     if (!empty($data[self::WEBSITE])) {
         $comment->setWebsite($data[self::WEBSITE]);
     }
     $comment->setContent($data[self::COMMENT]);
     $comment->setIpAddress($this->_request->getClientIp());
     if ($this->_user instanceof User) {
         $comment->setUserID($this->_user->id);
     }
     $this->_setStatus($comment, $content);
     return $comment;
 }