src/Controller/Frontend/AdmissionEnController.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Frontend;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use FOS\RestBundle\Controller\Annotations as Rest;
  5. use App\Misc\ImageUrlHelper;
  6. use App\Utilities\ServiceUtil;
  7. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  8. use Symfony\Contracts\Translation\TranslatorInterface;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use App\Annotation\Log;
  11. use App\Exception\BadRequestException;
  12. use App\Misc\CaptchaHelper;
  13. class AdmissionEnController extends BaseFrontendController
  14. {
  15.     /**
  16.      * @Route("/landing-agency/{slug}", name="admission", requirements={"slug": "[a-zA-Z0-9\-]+"})
  17.      */
  18.     public function index($slug) {
  19.         $landing $this->landingpageRepo->findOneBy(['slug' => $slug'isAgent' => 1]);
  20.         if (!$landing) {
  21.            return $this->render('pages/404.html.twig');
  22.         }
  23.         $this->addTitle('Admission');
  24.         $this->setDescription('Admission');
  25.         $data = [];
  26.         $data['landing'] = $this->landingpageService->autoMapper->map($landing'App\DTO\Landingpage\LandingpageOutput');
  27.         $data['studyLevels'] = $this->studyLevelRepository->findAll();
  28.         $data['cursuses'] = $this->cursusRepository->findAll();
  29.         $data['programsByLevel'] = $this->programService->getActiveProgramGroupByLevel();
  30.         // dd($data['programsByLevel']);
  31.         $france $this->countryRepo->find(1);
  32.         $data['countries'] = array_merge([$france], $this->countryRepo->getAll(['except_id' => 1'sort_asc' => 'name'], 'ENTITY'));
  33.         $data['departments'] = array_map(function ($department) {
  34.             return ['value' => $department'text' => $department];
  35.         }, $this->commonService->frenchDepartments);
  36.         $data['campuses'] = $this->campusRepository->getAll(['filter_status' => 1'memberOf_programs' => 'notNull','sort_asc' => 'ordering'], 'ENTITY');
  37.         $year date("Y");
  38.         if (date("Y-m-d") > date("Y") . '-10-01') {
  39.             $data['year'] = date('Y'strtotime('+1 year')) . '-' date('Y'strtotime('+2 year'));
  40.         } else {
  41.             $data['year'] = $year '-' date('Y'strtotime('+1 year'));
  42.         }
  43.         
  44.         return $this->render(
  45.             'admission/index.html.twig',
  46.             $data
  47.         );
  48.     }
  49.     /**
  50.      * @Rest\Get("/admission/campus", name="programs_by_campus")
  51.      */
  52.     public function getLandingPage(Request $request)
  53.     {
  54.         $id $request->get('campus');
  55.         $programsByLevel $this->programService->getActiveProgramGroupByLevel($id);
  56.         $select $this->container->get('twig')->render('admission/program_campus.html.twig', [
  57.             'programsByLevel' => $programsByLevel
  58.         ]);
  59.         return $this->json(ServiceUtil::processSuccessful(['html' => $select]));
  60.     }
  61.      /**
  62.      * @Rest\Post("/save-landing-page-agent", name="landingpage_agent.save")
  63.      * @Log
  64.      */
  65.     public function save(
  66.         Request $request,
  67.         CaptchaHelper $captchaHelper,
  68.         TranslatorInterface $translator
  69.     ) {
  70.         try {
  71.             $this->landingpageService->addProfileInLandingPage($request'App\DTO\Profile\AddProfileLandingpageInput');
  72.             return $this->json(ServiceUtil::processSuccessful());
  73.         } catch (BadRequestException $badRequestException) {
  74.             $messagesArr $badRequestException->getMessages();
  75.             foreach ($messagesArr['data'] as $field => $message) {
  76.                 $errorMessage $message;
  77.                 break;
  78.             }
  79.         }
  80.         $data['errorMessage'] = $errorMessage;
  81.         return $this->json(ServiceUtil::processFailed($data));
  82.     }
  83.     
  84. }