src/Controller/Frontend/ProgramController.php line 82

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Frontend;
  3. use App\Entity\OurStudent;
  4. use App\Entity\Program;
  5. use Symfony\Component\DependencyInjection\ContainerInterface;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use FOS\RestBundle\Controller\Annotations as Rest;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Contracts\Translation\TranslatorInterface;
  11. class ProgramController extends BaseFrontendController
  12. {
  13.     /**
  14.      * @Route("/{_locale}/{level}-estiam", requirements={"_locale": "en|fr"}, defaults={"_locale"="fr"}, name="level")
  15.      */
  16.     public function level($levelRequest $requestTranslatorInterface $translator): Response
  17.     {
  18.         $arrLevels = ['bts' => 1'bachelor' => 2'mba' => 3];
  19.         $this->addTitle($translator->trans('title.program-level-' $level));
  20.         $this->setDescription($translator->trans('desc.program-level-' $level));
  21.         if (isset($arrLevels[$level])) {
  22.             $data = [];
  23.             $data['cursus'] = null;
  24.             $data['level'] = $arrLevels[$level];
  25.             $programs $this->currentService->repository->findBy(['level' => $arrLevels[$level], 'status' => 1], ['name' => 'ASC']);
  26.             if ($programs) {
  27.                 $data['programs'] = $this->currentService->autoMapper->mapMultiple($programs'App\DTO\Program\ProgramOutput');
  28.             } else {
  29.                 $data['programs'] = null;
  30.             }
  31.             if ($arrLevels[$level] == 3) {
  32.                 $cursus $this->cursusService->repository->findAll();
  33.                 if ($cursus) {
  34.                     $data['cursus'] = $this->cursusService->autoMapper->mapMultiple($cursus'App\DTO\Cursus\CursusOutput');
  35.                 }
  36.             }
  37.         } else {
  38.             return $this->render('pages/404.html.twig');
  39.         }
  40.         return $this->render('programs/level.html.twig'$data);
  41.     }
  42.     /**
  43.      * @Route("/{_locale}/tarifs", requirements={"_locale": "en|fr"}, defaults={"_locale"="fr"}, name="tarifs")
  44.      */
  45.     public function tarifs(TranslatorInterface $translator): Response
  46.     {
  47.         $siteName $this->getParameter('site_name');
  48.         $this->addTitle($translator->trans('tarifs.title', [
  49.                 '%siteName%'  => $siteName
  50.             ]));
  51.         $this->setDescription($translator->trans('tarifs.desc',[
  52.                 '%siteName%'  => $siteName
  53.             ]));
  54.         return $this->render('programs/price.html.twig', []);
  55.     }
  56.     /**
  57.      * @Route("/{_locale}/formation-{slug}-alternance", requirements={"_locale": "en|fr", "slug": "[a-zA-Z0-9\-]+","id": "[0-9]+"}, defaults={"_locale"="fr"}, name="program_detail")
  58.      */
  59.     public function programDetail($slugRequest $requestTranslatorInterface $translator): Response
  60.     {
  61.         $program $this->currentService->repository->findOneBy(['slug' => $slug'status' => 1]);
  62.         if(!$program) {
  63.             return $this->render('pages/404.html.twig');
  64.         }
  65.         //301 redirect program no alternance
  66.         return $this->redirect('/fr/formation-' $program->getSlug());
  67.     }
  68.     /**
  69.      * @Route("/{_locale}/formation-{slug}", requirements={"_locale": "en|fr", "slug": "[a-zA-Z0-9\-]+","id": "[0-9]+"}, defaults={"_locale"="fr"}, name="program_detail_no_alternance")
  70.      */
  71.     public function programDetailNoAlternance($slugRequest $requestTranslatorInterface $translator): Response
  72.     {
  73.         $data = [];
  74.         $program $this->currentService->repository->findOneBy(['slug' => $slug'status' => 1]);
  75.         if ($program) {
  76.             $data['outStudentVideos'] = $this->ourStudentRepo->getAllOurStudentByType(OurStudent::TYPE_VIDEO3);
  77.             $data['program'] = $this->currentService->autoMapper->map($program'App\DTO\Program\ProgramOutput');
  78.             $programTranning = [];
  79.             if ($data['program']->level == 1) {
  80.                 $data['tranningText'] = Program::TRANNING_BTS;
  81.             } elseif ($data['program']->level == 2) {
  82.                 $data['tranningText'] = Program::TRANNING_BACHELOR;
  83.             } elseif ($data['program']->level == 3) {
  84.                 $data['tranningText'] = Program::TRANNING_MBA;
  85.             }
  86.         } else {
  87.             return $this->render('pages/404.html.twig');
  88.         }
  89.         $this->addTitle(
  90.             isset($data['program']->metadata['tags']['seoTitle']) ? $data['program']->metadata['tags']['seoTitle'] : $translator->trans('program.title', [
  91.                 '%programName%' => $data['program']->name,
  92.                 '%level%' => $translator->trans('program_level' . ($data['program']->level))
  93.             ])
  94.         );
  95.         $this->setDescription(isset($data['program']->metadata['tags']['seoDescription']) ? $data['program']->metadata['tags']['seoDescription'] : $data['program']->description);
  96.         return $this->render('programs/program_detail.html.twig'$data);
  97.     }
  98. }