src/Controller/ZStaticPageController.php line 77

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Image\ImageEntity;
  4. use App\Form\CMS\CmsType;
  5. use App\Service\AnimationLinkRetriverService;
  6. use App\Service\EditService;
  7. use App\Service\UserSeasonService;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as Controller;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use App\Entity\StaticPage;
  15. class ZStaticPageController extends Controller
  16. {
  17.     /**
  18.      * @Route(
  19.      *     "/page-statique/modification/{slug}/{id}",
  20.      *     defaults={"slug"="", "id"=1},
  21.      *     name="static_edit"
  22.      * )
  23.      */
  24.     public function edit(
  25.         AnimationLinkRetriverService $animationService,
  26.         EditService $editService,
  27.         EntityManagerInterface $em,
  28.         Request $request,
  29.         string $slug,
  30.         int $id
  31.     ){
  32.         $roles = ['ROLE_ADMIN_PLATFORM'];
  33.         $type 'static';
  34.         $formClass CmsType::class;
  35.         $event $em->getRepository(StaticPage::class)->find($id);
  36.         if ($return $editService->checkEventAuthorization($request$id$slug$roles$type$eventtrue)) {
  37.             return $return;
  38.         }
  39.         $animationGroupes $animationService->retriveAnimationGroupe($event->getAnimationGroups());
  40.         return $this->render('StaticPage/edit.html.twig',
  41.             array_merge($editService->returnForm($request$formClass$type$event), [
  42.                 'animationGroupes' => $animationGroupes,
  43.                 'isEdit'           => true,
  44.             ])
  45.         );
  46.     }
  47.     /**
  48.      * @Route(
  49.      *     "/page-statique/{id}/{slug}",
  50.      *     defaults={"slug"="", "id"=1},
  51.      *     name="static_view"
  52.      *)
  53.      */
  54.     public function staticView(EntityManagerInterface $em$slug$id)
  55.     {
  56.         $static $em->getRepository(StaticPage::class)->find($id);
  57.         if (null === $static) {
  58.             throw new NotFoundHttpException('app.error.404');
  59.         }
  60.         return $this->redirect($static->getRelativeUrl());
  61.     }
  62.     /**
  63.      * @Route("/{uri}/")
  64.      * @Route("/{uri}/{uri_Two}/")
  65.      * @Route("/{uri}/{uri_Two}/{uri_Three}/")
  66.      * @ParamConverter("staticPage", class="App\Entity\StaticPage", options={
  67.      *    "repository_method" = "getStaticByUri",
  68.      *    "mapping": {"uri": "uriOne", "uri_Two": "uriTwo", "uri_Three": "uriThree"},
  69.      *    "map_method_signature" = true
  70.      * })
  71.      */
  72.     public function view(
  73.         AnimationLinkRetriverService $animationService,
  74.         StaticPage $staticPage
  75.     ){
  76.         $animationGroupes $animationService->retriveAnimationGroupe($staticPage->getAnimationGroups());
  77.         $canEdit false;
  78.         if (
  79.             $this->isGranted('ROLE_ADMIN_PLATFORM') &&
  80.             (empty($this->getUser()->getTestUserType()) || $this->getUser()->getTestUserType() === 'ADMIN')
  81.         ) {
  82.             $canEdit true;
  83.         }
  84.         return $this->render('StaticPage/view.html.twig', [
  85.             'event'           => $staticPage,
  86.             'animationGroupes' => $animationGroupes,
  87.             'origine'          => 'static',
  88.             'canEdit'          => $canEdit
  89.         ]);
  90.     }
  91. }