src/Controller/DefaultController.php line 127

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  7. /**
  8. * @Route("")
  9. */
  10. class DefaultController extends AbstractController {
  11.     /**
  12.      * @Route("/", name="homepage", methods={"GET"})
  13.      */
  14.     public function homepage(
  15.         \App\Repository\BlogArticleRepository $blogArticleRepository,
  16.         \App\Repository\CourseRepository $courseRepository,
  17.         \App\Repository\CareerPathRepository $careerPathRepository
  18.     ): Response {
  19.         $latestArticles $blogArticleRepository->findBy(["isEnabled" => true],["createdAt" => "DESC"],3);
  20.         $latestCourses $courseRepository->findBy(["isEnabled" => true],["createdAt" => "DESC"],3);
  21.         $latestCareerPaths $careerPathRepository->findBy(["isEnabled" => true],["createdAt" => "DESC"],3);
  22.         return $this->render('client/default/home.html.twig', [
  23.             "latestCareerPaths" => $latestCareerPaths,
  24.             "latestCourses" => $latestCourses,
  25.             "latestArticles" => $latestArticles
  26.         ]);
  27.     }
  28.     /**
  29.      * @Route("/payment-refund/", name="payment_refund", methods={"GET"})
  30.      */
  31.     public function paymentRefunds(
  32.         \App\Service\SeoHelper $seoHelper,
  33.         \App\Repository\PageRepository $pageRepository
  34.     ): Response {
  35.         $page $pageRepository->findOneBy(["slug" => "payment-refund"]);
  36.         if (!$page) throw $this->createNotFoundException('The page does not exist');
  37.         $seoHelper->setPageSeo($page'payment_refund');
  38.         return $this->render('client/default/page.html.twig', [
  39.             "page" => $page
  40.         ]);
  41.     }
  42.     /**
  43.      * @Route("/about/", name="about", methods={"GET"})
  44.      */
  45.     public function about(
  46.         \App\Service\SeoHelper $seoHelper,
  47.         \App\Repository\PageRepository $pageRepository
  48.     ): Response {
  49.         $page $pageRepository->findOneBy(["slug" => "about"]);
  50.         if (!$page) throw $this->createNotFoundException('The page does not exist');
  51.         $seoHelper->setPageSeo($page'about');
  52.         return $this->render('client/default/page.html.twig', [
  53.             "page" => $page
  54.         ]);
  55.     }
  56.     /**
  57.      * @Route("/contact/", name="contact", methods={"GET"})
  58.      */
  59.     public function contact(
  60.         \Symfony\Component\HttpFoundation\Request $request,
  61.         \App\Service\EmailHelper $emailHelper,
  62.         \App\Service\SeoHelper $seoHelper,
  63.         \App\Repository\PageRepository $pageRepository
  64.     ): Response {
  65.         $page $pageRepository->findOneBy(["slug" => "contact"]);
  66.         //if (!$page) throw $this->createNotFoundException('The page does not exist');
  67.         //$seoHelper->setPageSeo($page, 'contact');
  68.         $form $this->createForm(\App\Form\ContactFormType::class);
  69.         $form->handleRequest($request);
  70.         if ($form->isSubmitted() && $form->isValid()) :
  71.             $contact = new stdClass();
  72.             $contact->name $form->get('name')->getData();
  73.             $contact->email $form->get('email')->getData();
  74.             $contact->phone $form->get('phone')->getData();
  75.             $contact->message $form->get('message')->getData();
  76.             $emailHelper->sendNewContactAdmin($contact);
  77.             $this->addFlash(
  78.                 'success',
  79.                 'Thank you for your contact!'
  80.             );
  81.             unset($form);
  82.             $form $this->createForm(\App\Form\ContactFormType::class);
  83.         endif;
  84.         return $this->render('client/default/contact.html.twig', [
  85.             'contactForm' => $form->createView(),
  86.             "page" => $page
  87.         ]);
  88.     }
  89.     /**
  90.      * @Route("/affiliates/", name="affiliates", methods={"GET"})
  91.      */
  92.     public function affiliates(
  93.         \App\Service\SeoHelper $seoHelper,
  94.         \App\Repository\PageRepository $pageRepository
  95.     ): Response {
  96.         $page $pageRepository->findOneBy(["slug" => "affiliates"]);
  97.         if (!$page) throw $this->createNotFoundException('The page does not exist');
  98.         $seoHelper->setPageSeo($page'affiliates');
  99.         return $this->render('client/default/page.html.twig', [
  100.             "page" => $page
  101.         ]);
  102.     }
  103.     /**
  104.      * @Route("/privacy/", name="privacy", methods={"GET"})
  105.      */
  106.     public function privacy(
  107.         \App\Service\SeoHelper $seoHelper,
  108.         \App\Repository\PageRepository $pageRepository
  109.     ): Response {
  110.         $page $pageRepository->findOneBy(["slug" => "privacy"]);
  111.         if (!$page) throw $this->createNotFoundException('The page does not exist');
  112.         $seoHelper->setPageSeo($page'privacy');
  113.         return $this->render('client/default/page.html.twig', [
  114.             "page" => $page
  115.         ]);
  116.     }
  117.     /**
  118.      * @Route("/career-development/", name="career_development", methods={"GET"})
  119.      */
  120.     public function careerDevelopment(
  121.         \App\Service\SeoHelper $seoHelper,
  122.         \App\Repository\PageRepository $pageRepository
  123.     ): Response {
  124.         $page $pageRepository->findOneBy(["slug" => "career-development"]);
  125.         if (!$page) throw $this->createNotFoundException('The page does not exist');
  126.         $seoHelper->setPageSeo($page'career_development');
  127.         return $this->render('client/default/page.html.twig', [
  128.             "page" => $page
  129.         ]);
  130.     }
  131.     /**
  132.      * @Route("/terms/", name="terms", methods={"GET"})
  133.      */
  134.     public function terms(
  135.         \App\Service\SeoHelper $seoHelper,
  136.         \App\Repository\PageRepository $pageRepository
  137.     ): Response {
  138.         $page $pageRepository->findOneBy(["slug" => "terms"]);
  139.         if (!$page) throw $this->createNotFoundException('The page does not exist');
  140.         $seoHelper->setPageSeo($page'terms');
  141.         return $this->render('client/default/page.html.twig', [
  142.             "page" => $page
  143.         ]);
  144.     }
  145.     /**
  146.      * @Route("/demo/", name="demo", methods={"GET"})
  147.      */
  148.     public function demo(): Response {
  149.         return $this->render('client/default/demo.html.twig', [
  150.         ]);
  151.     }
  152. }