src\Controller\Site\VideosController.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Site;
  3. use App\Controller\BaseController;
  4. use App\Entity\VideoVisit;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Cookie;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use Knp\Component\Pager\PaginatorInterface;
  12. use App\Entity\Video;
  13. use App\Repository\VideoRepository;
  14. use App\Repository\CategorieVideoRepository;
  15. class VideosController extends BaseController
  16. {
  17.     private $em,$paginator;
  18.     public function __construct(EntityManagerInterface $emPaginatorInterface $paginator)
  19.     {
  20.         $this->em=$em;
  21.         $this->paginator $paginator;
  22.     }
  23.     /**
  24.      * @Route("/videos", name="site_videos")
  25.      */
  26.     public function index(Request $requestVideoRepository $VideoRepository,CategorieVideoRepository $CategorieVideoRepository):Response
  27.     {
  28.           $status=true;          
  29.           $q=($request->query->get('q'))?$request->query->get('q'):'';
  30.           $all$VideoRepository->findBylist($status,$q);
  31.           $paginedData=$this->paginator->paginate($all,$request->query->getInt('page'1),9);
  32.           //dd($all);
  33.         return $this->render('site/videos/videos.html.twig', [
  34.             'title' => 'Vidéos'
  35.             //'videos'=>  $VideoRepository->findBylist($status),
  36.             'ALL'=> $paginedData,
  37.             'categories'=>$CategorieVideoRepository->FindAll(),
  38.         ]);
  39.     }
  40.     /**
  41.      * @Route("/videos/show/{id}/{cat?}", name="site_videos_show")
  42.      */
  43.     public function show(Request $request,VideoRepository $VideoRepository,Video $Video,CategorieVideoRepository $CategorieVideoRepository):Response
  44.     {
  45.          $cat=$request->attributes->get('cat');
  46.          //if ($Video->getPremium()){
  47.              if ($this->isGranted('IS_AUTHENTICATED_FULLY')){
  48.                  $visit = (new VideoVisit())->setUser($this->getUser())
  49.                  ->setVideo($Video)
  50.                  ->setIp($request->getClientIp())
  51.                  ->setUserAgent($_SERVER['HTTP_USER_AGENT']);
  52.                  $this->em->persist($visit);
  53.                  $this->em->flush();
  54.              }else{
  55.                  //$request->headers->set('referer','');
  56.                  return $this->redirectToRoute('app_login');
  57.              }
  58.          //}
  59.          $status=true;
  60.          // dd($cat);
  61.         return $this->render('site/videos/detailsvideos.html.twig', [
  62.             'title' => 'Details Vidéos',
  63.             'videos' => $VideoRepository->findBycateg($status,$cat),
  64.             'video' => $Video,
  65.             //'cat'=>$cat,
  66.             'categories'=>$CategorieVideoRepository->FindAll(),
  67.         ]);
  68.     }
  69.     
  70.     /**
  71.      * @Route("/videos/categorie/{id}", name="site_videos_cat")
  72.      */
  73.     public function VideoCat(Request $request,VideoRepository $VideoRepository,CategorieVideoRepository $CategorieVideoRepository):Response
  74.     {
  75.       $cat=$request->attributes->get('id');
  76.        $status=true;
  77.         return $this->render('site/videos/videocat.html.twig', [
  78.             'title' => 'Details Vidéos',
  79.             'videos' => $VideoRepository->findBycateg($status,$cat),
  80.             'cat'=>$cat,
  81.             'categories'=>$CategorieVideoRepository->FindAll(),
  82.         ]);
  83.     }
  84.     /**
  85.      * @Route("/voeux/{id}", name="voeux_show", methods={"GET"})
  86.      */
  87.     public function Voeuxshow(Video $video): Response
  88.     {
  89.         return $this->render('site/videos/voeux.html.twig', [
  90.             'video' => $video,
  91.         ]);
  92.     }
  93. }