public function createComment($resourceId, CommentAction $comment)
 {
     $resourceNode = $this->resourceNodeRepository->find($resourceId);
     $comment->setResource($resourceNode);
     $this->em->persist($comment);
     $this->wallItemManager->createWallItem($comment);
     $this->em->flush();
 }
 /**
  * @Route("/comment/{resourceId}", name="icap_socialmedia_comment")
  * @Method({"POST"})
  * @ParamConverter("user", options={"authenticatedUser" = true})
  * @param $resourceId
  * @param User $user
  * @return bool
  */
 public function commentAction(Request $request, $resourceId, User $user)
 {
     $text = $request->get("social_media_comment_text");
     if ($text !== null) {
         $comment = new CommentAction();
         $comment->setText($text);
         $comment->setUser($user);
         $commentManager = $this->getCommentActionManager();
         $userIds = $commentManager->getHasCommentedUserIds($resourceId);
         $commentManager->createComment($resourceId, $comment);
         $this->dispatchCommentEvent($comment, $userIds);
     }
     if ($request->isXmlHttpRequest()) {
         $response = new JsonResponse(true);
     } else {
         $response = $this->redirectToRoute("icap_socialmedia_comments_view", array("resourceId" => $resourceId));
     }
     return $response;
 }
 protected function dispatchCommentEvent(CommentAction $comment, $userIds)
 {
     $resource = $comment->getResource();
     if ($resource !== null) {
         $event = new LogSocialmediaCommentEvent($comment, $userIds);
         return $this->dispatch($event);
     }
 }
 public function __construct(CommentAction $comment, $userIds)
 {
     $this->details = array();
     $this->userIds = $userIds;
     parent::__construct($comment->getResource(), $this->details);
 }