<?php declare(strict_types=1);
namespace App\Controller\ShopVideo;
use App\Doctrine\Cache\CacheDecider;
use App\Entity\ShopVideo;
use App\Exception\ShopVideoNotFoundException;
use App\Repository\ShopVideoRepository;
/**
* @extends \App\Controller\CRUD\DetailsController<ShopVideo>
*/
class DetailsController extends \App\Controller\CRUD\DetailsController
{
private CacheDecider $cacheDecider;
public function __construct(CacheDecider $cacheDecider)
{
$this->cacheDecider = $cacheDecider;
parent::__construct(ShopVideo::class, 'shop_video/details.html.twig');
}
/**
* @param array<string, array<mixed>|bool|int|float|object|string|null> $filters
*/
public function provideEntity(array $filters): ShopVideo
{
if (!isset($filters['id']) || !is_string($filters['id'])) {
throw $this->createNotFoundException('Id parameter is required.');
}
/** @var ShopVideoRepository $repository */
$repository = $this->getRepository();
/**
* @var ?ShopVideo $shopVideo
*/
$shopVideo = $repository->filterOneResult($repository->applyPublicFilters([
'stringId' => $filters['id'],
]), $this->cacheDecider);
if (null === $shopVideo) {
throw new ShopVideoNotFoundException();
}
return $shopVideo;
}
}