public function prePersist(Comment $comment, LifecycleEventArgs $event) { if ($comment->getMessage() != null) { $userPicker = new UserPickerContent($comment->getMessage()); $comment->setUserPicker($userPicker); $comment->setMessage($userPicker->getFinalText()); } }
/** * @param Post $post * @param Comment $comment */ public function __construct(Post $post, Comment $comment) { $this->blog = $post->getBlog(); $this->comment = $comment; $this->post = $post; $this->details = array('post' => array('blog' => $this->blog->getId(), 'title' => $post->getTitle(), 'slug' => $post->getSlug()), 'comment' => array('id' => $comment->getId(), 'content' => $comment->getMessage(), 'published' => $comment->isPublished(), 'author' => $comment->getAuthor()->getFirstName() . " " . $post->getAuthor()->getLastName(), 'authorId' => $comment->getAuthor()->getId())); parent::__construct($this->blog->getResourceNode(), $this->details); }
/** * @param Post $post * @param Comment $comment */ public function __construct(Post $post, Comment $comment) { $author = $comment->getAuthor(); $blog = $post->getBlog(); if (null === $author) { $author = "Anonyme"; } else { $author = $comment->getAuthor()->getFirstName() . ' ' . $comment->getAuthor()->getLastName(); } $details = array('post' => array('blog' => $blog->getId(), 'title' => $post->getTitle(), 'slug' => $post->getSlug()), 'comment' => array('id' => $comment->getId(), 'author' => $author, 'content' => $comment->getMessage())); parent::__construct($blog->getResourceNode(), $details); }