/** * @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); }
public function postPersist(Comment $comment, LifecycleEventArgs $event) { $userPicker = $comment->getUserPicker(); $post = $comment->getPost(); $blog = $post->getBlog(); if ($post->isPublished() && $comment->isPublished() && $userPicker !== null && count($userPicker->getUserIds()) > 0 && $blog->getResourceNode() !== null) { $details = array('post' => array('blog' => $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()), 'resource' => array('id' => $blog->getId(), 'name' => $blog->getResourceNode()->getName(), 'type' => $blog->getResourceNode()->getResourceType()->getName())); $notification = $this->notificationManager->createNotification('resource-icap_blog-comment-user_tagged', 'blog', $blog->getResourceNode()->getId(), $details); $this->notificationManager->notifyUsers($notification, $userPicker->getUserIds()); } }
/** * @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); }