Пример #1
0
 /**
  * @param array              $data
  * @param CommentInterface[] $comments
  *
  * @return \Pim\Bundle\CommentBundle\Model\CommentInterface
  */
 protected function createComment(array $data, array $comments)
 {
     $resource = $data['resource'];
     $createdAt = \DateTime::createFromFormat('j-M-Y', $data['created_at']);
     $comment = new Comment();
     $comment->setAuthor($this->getUser($data['author']));
     $comment->setCreatedAt($createdAt);
     $comment->setRepliedAt($createdAt);
     $comment->setBody($data['message']);
     $comment->setResourceName(ClassUtils::getClass($resource));
     $comment->setResourceId($resource->getId());
     if (isset($data['parent']) && !empty($data['parent'])) {
         $parent = $comments[$data['parent']];
         $parent->setRepliedAt($createdAt);
         $comment->setParent($parent);
         $this->validate($comment);
         $this->persist($parent);
     }
     $this->persist($comment);
     return $comment;
 }
 /**
  * {@inheritDoc}
  */
 public function setBody($body)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setBody', array($body));
     return parent::setBody($body);
 }