Esempio n. 1
0
 /**
  * Shows a video if you have the rights
  *
  */
 public function viewAction(Video $video)
 {
     $securityContext = $this->container->get('security.context');
     if ($video->getStatus() == "link") {
         throw $this->createNotFoundException('You must have the share link to view this video');
     } else {
         if ($video->getStatus() == "private" && !$securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
             return $this->redirect($this->generateUrl('fos_user_security_login'));
         } else {
             $nbViewCount = $video->getViewCount();
             $video->setViewCount($nbViewCount + 1);
             $em = $this->getDoctrine()->getManager();
             $em->persist($video);
             $em->flush();
             return $this->render('AppBundle:Video:view.html.twig', array('entity' => $video));
         }
     }
 }