private function injectData() { $requestUser = $this->requestStack->getCurrentRequest()->attributes->get('user'); if ($requestUser) { $userProfile = $requestUser->getId(); } else { $userProfile = $this->user; } $entity = $this->entityManager->getRepository('SnoozitUserBundle:User')->find($userProfile); if (!$entity) { throw new EntityNotFoundException("Ce profile n'existe pas."); } $userProfileComment = new UserProfileComment(); $userProfileComment->setUserProfile($entity); $userProfileComment->setUser($this->user); return $this->form->setData($userProfileComment); }
public function profileCommentAction(User $user, UserProfileComment $comment) { $em = $this->getDoctrine()->getManager(); $lastComment = $em->getRepository('SnoozitPlatformBundle:UserProfileComment')->findOneBy(array('userProfile' => $user), array('created' => 'desc')); $userFollow = $this->checkIfUserFollow($user); $breadcrumb = array(array('Profile de ' . $user->getUsername() . '', $this->generateUrl('fos_user_profile_show_name', array('username' => $user->getUsername())))); $commentToCommentHandler = $this->get('sz_user_profile_comment_to_comment_handler'); if ($commentToCommentHandler->process()) { return $this->redirect($this->generateUrl('fos_user_profile_show_comment', array('user' => $user->getId(), 'id' => $comment->getId()))); } $commentsToComment = $em->getRepository('SnoozitPlatformBundle:UserProfileCommentToComment')->findBy(array('userProfileComment' => $comment)); return $this->render('SnoozitUserBundle:Profile/Comment:comment.html.twig', array('breadcrumb' => $breadcrumb, 'comment' => $comment, 'user' => $user, 'lastComment' => $lastComment, 'userFollow' => $userFollow, 'commentsToComment' => $commentsToComment, 'form' => $commentToCommentHandler->createView())); }