src/Package/Openform/Front/Controller/RelictPackController.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Package\Openform\Front\Controller;
  3. use Doctrine\ORM\EntityManager;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\RequestStack;
  9. use App\Package\Openform\Front\Controller\BaseController;
  10. use App\Package\Toolkit\RouteLocalizer\RouteLocalizer;
  11. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  12. use App\Package\Openform\RepositoryFront\FrontRelictPackRepository;
  13. use Symfony\Component\Intl\Locales;
  14. /**
  15.  * PageController
  16.  *
  17.  * @author     Daniel Balowski <d.balowski@openform.pl> (_creator)
  18.  * @copyright  2019 Openform
  19.  * @since      07.2019
  20.  */
  21. class RelictPackController extends BaseController
  22. {
  23.     protected $routeLocalizer
  24.     private $em
  25.     private $relictPackRepo
  26.     private $pageRepo
  27.     public function __construct(RequestStack $requestRouteLocalizer $routeLocalizerEntityManagerInterface $em)
  28.     {
  29.         parent::__construct($request$routeLocalizer$em);
  30.         
  31.         $this->em $em;
  32.         $this->routeLocalizer $routeLocalizer;
  33.         $this->relictPackRepo $this->em->getRepository('Openform:RelictPack')->getFrontRepository();
  34.         $this->pageRepo $this->em->getRepository('Openform:Page')->getFrontRepository();
  35.     }    
  36.     public function itemAction(Request $requeststring $slug)
  37.     {
  38.         $locale $request->getLocale();
  39.         $repo $this->em->getRepository('Openform:RelictPack')->getFrontRepository();
  40.         $entity $repo->getVisibleBySlug($slug$locale);
  41.         if (!$entity) {
  42.             throw new NotFoundHttpException();
  43.         }
  44.         $rootParent \App\Package\Openform\Entity\RelictPack::getRootParent($entity);
  45.         $request->attributes->set('makSlug'$rootParent->getMakSlug($locale));
  46.         
  47.         return $this->render('@openform_front_templates/RelictPack/item.html.twig', [
  48.             'entity' => $entity,
  49.             'parentPage' => $entity->getParent(),
  50.             'rootParent' => $rootParent
  51.         ]);
  52.     }
  53.     
  54.     public function relictItemAction(Request $requeststring $slug)
  55.     {
  56.         $locale $request->getLocale();
  57.         $repo $this->em->getRepository('Openform:Relict')->getFrontRepository();
  58.         $entity $repo->getVisibleBySlug($slug$locale);
  59.         if (!$entity) {
  60.             throw new NotFoundHttpException();
  61.         }
  62.         $rootParent \App\Package\Openform\Entity\RelictPack::getRootParent($entity->getRelictPack());
  63.         $request->attributes->set('makSlug'$rootParent->getMakSlug($locale));
  64.                 
  65.         return $this->render('@openform_front_templates/RelictPack/relict_item.html.twig', [
  66.             'entity' => $entity,
  67.             'parentPage' => $entity->getRelictPack(),
  68.             'rootParent' => $rootParent
  69.         ]);
  70.     }
  71. }