/** * @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); }
/** * @Route("/{blogId}/{postSlug}/comment/edit/{commentId}", name="icap_blog_comment_edit", requirements={"blogId" = "\d+"}) * * @ParamConverter("blog", class="IcapBlogBundle:Blog", options={"id" = "blogId"}) * @ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postSlug": "slug"}}) * @ParamConverter("comment", class="IcapBlogBundle:Comment", options={"id" = "commentId"}) * @Template() */ public function editAction(Request $request, Blog $blog, Post $post, Comment $comment) { $user = $this->get('security.token_storage')->getToken()->getUser(); $translator = $this->get('translator'); if ($user != null && $user->getId() == $comment->getAuthor()->getId()) { $messages = array('success' => $translator->trans('icap_blog_comment_edit_success', array(), 'icap_blog'), 'error' => $translator->trans('icap_blog_comment_edit_error', array(), 'icap_blog')); return $this->persistCommentUpdate($request, $blog, $post, $comment, $user, $messages); } else { throw new AccessDeniedException($translator->trans('icap_blog_comment_access_denied', array(), 'icap_blog')); } }