<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
/**
* @Route("")
*/
class DefaultController extends AbstractController {
/**
* @Route("/", name="homepage", methods={"GET"})
*/
public function homepage(
\App\Repository\BlogArticleRepository $blogArticleRepository,
\App\Repository\CourseRepository $courseRepository,
\App\Repository\CareerPathRepository $careerPathRepository
): Response {
$latestArticles = $blogArticleRepository->findBy(["isEnabled" => true],["createdAt" => "DESC"],3);
$latestCourses = $courseRepository->findBy(["isEnabled" => true],["createdAt" => "DESC"],3);
$latestCareerPaths = $careerPathRepository->findBy(["isEnabled" => true],["createdAt" => "DESC"],3);
return $this->render('client/default/home.html.twig', [
"latestCareerPaths" => $latestCareerPaths,
"latestCourses" => $latestCourses,
"latestArticles" => $latestArticles
]);
}
/**
* @Route("/payment-refund/", name="payment_refund", methods={"GET"})
*/
public function paymentRefunds(
\App\Service\SeoHelper $seoHelper,
\App\Repository\PageRepository $pageRepository
): Response {
$page = $pageRepository->findOneBy(["slug" => "payment-refund"]);
if (!$page) throw $this->createNotFoundException('The page does not exist');
$seoHelper->setPageSeo($page, 'payment_refund');
return $this->render('client/default/page.html.twig', [
"page" => $page
]);
}
/**
* @Route("/about/", name="about", methods={"GET"})
*/
public function about(
\App\Service\SeoHelper $seoHelper,
\App\Repository\PageRepository $pageRepository
): Response {
$page = $pageRepository->findOneBy(["slug" => "about"]);
if (!$page) throw $this->createNotFoundException('The page does not exist');
$seoHelper->setPageSeo($page, 'about');
return $this->render('client/default/page.html.twig', [
"page" => $page
]);
}
/**
* @Route("/contact/", name="contact", methods={"GET"})
*/
public function contact(
\Symfony\Component\HttpFoundation\Request $request,
\App\Service\EmailHelper $emailHelper,
\App\Service\SeoHelper $seoHelper,
\App\Repository\PageRepository $pageRepository
): Response {
$page = $pageRepository->findOneBy(["slug" => "contact"]);
//if (!$page) throw $this->createNotFoundException('The page does not exist');
//$seoHelper->setPageSeo($page, 'contact');
$form = $this->createForm(\App\Form\ContactFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) :
$contact = new stdClass();
$contact->name = $form->get('name')->getData();
$contact->email = $form->get('email')->getData();
$contact->phone = $form->get('phone')->getData();
$contact->message = $form->get('message')->getData();
$emailHelper->sendNewContactAdmin($contact);
$this->addFlash(
'success',
'Thank you for your contact!'
);
unset($form);
$form = $this->createForm(\App\Form\ContactFormType::class);
endif;
return $this->render('client/default/contact.html.twig', [
'contactForm' => $form->createView(),
"page" => $page
]);
}
/**
* @Route("/affiliates/", name="affiliates", methods={"GET"})
*/
public function affiliates(
\App\Service\SeoHelper $seoHelper,
\App\Repository\PageRepository $pageRepository
): Response {
$page = $pageRepository->findOneBy(["slug" => "affiliates"]);
if (!$page) throw $this->createNotFoundException('The page does not exist');
$seoHelper->setPageSeo($page, 'affiliates');
return $this->render('client/default/page.html.twig', [
"page" => $page
]);
}
/**
* @Route("/privacy/", name="privacy", methods={"GET"})
*/
public function privacy(
\App\Service\SeoHelper $seoHelper,
\App\Repository\PageRepository $pageRepository
): Response {
$page = $pageRepository->findOneBy(["slug" => "privacy"]);
if (!$page) throw $this->createNotFoundException('The page does not exist');
$seoHelper->setPageSeo($page, 'privacy');
return $this->render('client/default/page.html.twig', [
"page" => $page
]);
}
/**
* @Route("/career-development/", name="career_development", methods={"GET"})
*/
public function careerDevelopment(
\App\Service\SeoHelper $seoHelper,
\App\Repository\PageRepository $pageRepository
): Response {
$page = $pageRepository->findOneBy(["slug" => "career-development"]);
if (!$page) throw $this->createNotFoundException('The page does not exist');
$seoHelper->setPageSeo($page, 'career_development');
return $this->render('client/default/page.html.twig', [
"page" => $page
]);
}
/**
* @Route("/terms/", name="terms", methods={"GET"})
*/
public function terms(
\App\Service\SeoHelper $seoHelper,
\App\Repository\PageRepository $pageRepository
): Response {
$page = $pageRepository->findOneBy(["slug" => "terms"]);
if (!$page) throw $this->createNotFoundException('The page does not exist');
$seoHelper->setPageSeo($page, 'terms');
return $this->render('client/default/page.html.twig', [
"page" => $page
]);
}
/**
* @Route("/demo/", name="demo", methods={"GET"})
*/
public function demo(): Response {
return $this->render('client/default/demo.html.twig', [
]);
}
}