src/Action/PressSite/Product/NewMoviesAction.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Action\PressSite\Product;
  3. use App\Action\PressSite\DomainAwareAction;
  4. use App\Contract\PressSite\Language\Switcher\GenericActionInterface;
  5. use App\Service\PressSite\Content\Callback\NewMoviesCallback;
  6. use App\Service\PressSite\Content\MovieContentBuilder;
  7. use App\Service\PressSite\DomainAwareManager;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  11. use Twig\Environment;
  12. /**
  13.  * Class NewMoviesAction.
  14.  */
  15. class NewMoviesAction extends DomainAwareAction implements GenericActionInterface
  16. {
  17.     /**
  18.      * The custom content builder responsible for returning the list with new movies.
  19.      *
  20.      * @var \App\Service\PressSite\Content\MovieContentBuilder
  21.      */
  22.     private $contentBuilder;
  23.     public function __construct(
  24.         Environment $twig,
  25.         DomainAwareManager $domainAwareManager,
  26.         MovieContentBuilder $contentBuilder
  27.     ) {
  28.         parent::__construct($twig$domainAwareManager);
  29.         $this->contentBuilder $contentBuilder;
  30.     }
  31.     /**
  32.      * Responsible for returning a collection of products.
  33.      *
  34.      * @param \Symfony\Component\HttpFoundation\Request $request
  35.      *   The current request object
  36.      *
  37.      * @return \Symfony\Component\HttpFoundation\Response
  38.      *   The response object
  39.      */
  40.     public function __invoke(Request $request): Response
  41.     {
  42.         // Theatrical sites do not have the new movies content page.
  43.         if ($this->getDomainManager()->getCurrentByHostnameAndLocale()->isBroadcastType()) {
  44.             throw new NotFoundHttpException('Page not found');
  45.         }
  46.         $this->contentBuilder->addCallback(new NewMoviesCallback());
  47.         return $this->render('press_site/actions/movies/new_movies.html.twig', [
  48.             'collection' => $this->contentBuilder->getContent(16MovieContentBuilder::SORT_ORDER_DESC),
  49.         ]);
  50.     }
  51. }