<?php
/*
* @since 1.0.0
* @copyright Copyright (C) 2020 ArtMedia. All rights reserved.
* @website http://artmedia.biz.pl
* @author Arkadiusz Tobiasz
* @email kontakt@artmedia.biz.pl
*/
namespace App\Controller\Media;
use App\Controller\AbstractController;
use App\Entity\Media\Album;
use App\Entity\Media\Photo;
use App\Entity\Media\Media;
use App\Entity\Profile;
use App\Entity\Core\Tag;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatableMessage;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\JsonResponse;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use App\Utils\Core\Image;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use App\Settings\SettingsManager;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/**
*
* @Route("/media")
*/
class MediaController extends AbstractController
{
/**
* @Route("/", defaults={"page": "1"}, name="media_index", methods="GET|POST")
* @Route("/page/{page<[1-9]\d*>}", methods={"GET|POST"}, name="media_index_paginated")
*/
public function index(
Request $request,
int $page = 1
): Response
{
$media = $this->getDoctrine()->getRepository(Media::class)->getList($page);
return $this->renderTemplate('media/media/index.html.twig', [
'paginator' => $media,
'route' => 'media_index_paginated',
], [
'%page%' => $page,
]);
}
/**
* @Route("/tag/{tag}", defaults={"page": "1"}, name="media_tag", methods="GET|POST")
* @Route("/tag/{tag}/page/{page<[1-9]\d*>}", methods={"GET|POST"}, name="media_tag_paginated")
* @ParamConverter("tag", class="App\Entity\Core\Tag", options={"mapping": {"tag": "slug"}})
*/
public function tag(
Request $request,
int $page = 1,
Tag $tag
): Response
{
$media = $this->getDoctrine()->getRepository(Media::class)->getTagList($page, $tag);
return $this->renderTemplate('media/media/tag.html.twig', [
'paginator' => $media,
'route' => 'media_tag_paginated',
'pageParams' => [
'tag' => $tag->getSlug(),
],
'tag' => $tag,
], [
'%tag%' => $tag->getName(),
'%page%' => $page,
]);
}
}