src/App/Controller/ShopVideo/DetailsController.php line 45

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Controller\ShopVideo;
  3. use App\Doctrine\Cache\CacheDecider;
  4. use App\Entity\ShopVideo;
  5. use App\Exception\ShopVideoNotFoundException;
  6. use App\Repository\ShopVideoRepository;
  7. /**
  8.  * @extends \App\Controller\CRUD\DetailsController<ShopVideo>
  9.  */
  10. class DetailsController extends \App\Controller\CRUD\DetailsController
  11. {
  12.     private CacheDecider $cacheDecider;
  13.     public function __construct(CacheDecider $cacheDecider)
  14.     {
  15.         $this->cacheDecider $cacheDecider;
  16.         parent::__construct(ShopVideo::class, 'shop_video/details.html.twig');
  17.     }
  18.     /**
  19.      * @param array<string, array<mixed>|bool|int|float|object|string|null> $filters
  20.      */
  21.     public function provideEntity(array $filters): ShopVideo
  22.     {
  23.         if (!isset($filters['id']) || !is_string($filters['id'])) {
  24.             throw $this->createNotFoundException('Id parameter is required.');
  25.         }
  26.         /** @var ShopVideoRepository $repository */
  27.         $repository $this->getRepository();
  28.         /**
  29.          * @var ?ShopVideo $shopVideo
  30.          */
  31.         $shopVideo $repository->filterOneResult($repository->applyPublicFilters([
  32.             'stringId' => $filters['id'],
  33.         ]), $this->cacheDecider);
  34.         if (null === $shopVideo) {
  35.             throw new ShopVideoNotFoundException();
  36.         }
  37.         return $shopVideo;
  38.     }
  39. }