src/Controller/Media/MediaController.php line 61

Open in your IDE?
  1. <?php
  2. /*
  3.  * @since 1.0.0
  4.  * @copyright Copyright (C) 2020 ArtMedia. All rights reserved.
  5.  * @website http://artmedia.biz.pl
  6.  * @author Arkadiusz Tobiasz
  7.  * @email kontakt@artmedia.biz.pl
  8.  */
  9. namespace App\Controller\Media;
  10. use App\Controller\AbstractController;
  11. use App\Entity\Media\Album;
  12. use App\Entity\Media\Photo;
  13. use App\Entity\Media\Media;
  14. use App\Entity\Profile;
  15. use App\Entity\Core\Tag;
  16. use Symfony\Component\HttpFoundation\RedirectResponse;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. use Symfony\Component\HttpFoundation\Response;
  20. use Symfony\Component\Translation\TranslatableMessage;
  21. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  22. use Symfony\Component\HttpFoundation\JsonResponse;
  23. use Liip\ImagineBundle\Imagine\Cache\CacheManager;
  24. use App\Utils\Core\Image;
  25. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  26. use App\Settings\SettingsManager;
  27. use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
  28. /**
  29.  * 
  30.  * @Route("/media")
  31.  */
  32. class MediaController extends AbstractController
  33. {
  34.     /**
  35.      * @Route("/", defaults={"page": "1"}, name="media_index", methods="GET|POST")
  36.      * @Route("/page/{page<[1-9]\d*>}", methods={"GET|POST"}, name="media_index_paginated")
  37.      */
  38.     public function index(
  39.         Request $request
  40.         int $page 1
  41.     ): Response
  42.     {
  43.         $media $this->getDoctrine()->getRepository(Media::class)->getList($page);
  44.         return $this->renderTemplate('media/media/index.html.twig', [
  45.             'paginator' => $media,
  46.             'route' => 'media_index_paginated',
  47.         ], [
  48.             '%page%' => $page,
  49.         ]);
  50.     }
  51.     /**
  52.      * @Route("/tag/{tag}", defaults={"page": "1"}, name="media_tag", methods="GET|POST")
  53.      * @Route("/tag/{tag}/page/{page<[1-9]\d*>}", methods={"GET|POST"}, name="media_tag_paginated")
  54.      * @ParamConverter("tag", class="App\Entity\Core\Tag", options={"mapping": {"tag": "slug"}})
  55.      */
  56.     public function tag(
  57.         Request $request
  58.         int $page 1,
  59.         Tag $tag
  60.     ): Response
  61.     {
  62.         $media $this->getDoctrine()->getRepository(Media::class)->getTagList($page$tag);
  63.         return $this->renderTemplate('media/media/tag.html.twig', [
  64.             'paginator' => $media,
  65.             'route' => 'media_tag_paginated',
  66.             'pageParams' => [
  67.                 'tag' => $tag->getSlug(),
  68.             ],
  69.             'tag' => $tag,
  70.         ], [
  71.             '%tag%' => $tag->getName(),
  72.             '%page%' => $page,
  73.         ]);
  74.     }
  75. }