src/Controller/AboutUsController.php line 203

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: Mariem
  5.  * Date: 02/04/2018
  6.  * Time: 12:19
  7.  */
  8. namespace App\Controller;
  9. use App\Business\ContactUs;
  10. use App\Business\DataSubjectAccessRequest;
  11. use App\Business\VulnerabilityDisclosure;
  12. use App\Form\ContactUsType;
  13. use App\Form\DataSubjectAccessRequestType;
  14. use App\Form\VulnerabilityDisclosureType;
  15. use App\Security\SecurityConstants;
  16. use App\Services\AboutUsService;
  17. use App\Services\RecaptchaService;
  18. use App\Services\VulnerabilityDisclosureService;
  19. use App\Utils\Helper;
  20. use Psr\Log\LoggerInterface;
  21. use Symfony\Component\Routing\Annotation\Route;
  22. use Symfony\Component\HttpFoundation\JsonResponse;
  23. use Symfony\Component\HttpFoundation\Request;
  24. use Symfony\Component\HttpFoundation\Response;
  25. use Symfony\Component\Security\Core\Security;
  26. class AboutUsController extends BaseController
  27. {
  28.     /** @var AboutUsService $insightService */
  29.     protected $aboutUsService;
  30.     /** @var RecaptchaService $recaptchaService */
  31.     protected $recaptchaService;
  32.     /** @var VulnerabilityDisclosureService $vulnerabilityDisclosureService */
  33.     protected $vulnerabilityDisclosureService;
  34.     /** @var Security $security */
  35.     protected Security $security;
  36.     public function __construct(AboutUsService $aboutUsServiceRecaptchaService $recaptchaService,
  37.                                 VulnerabilityDisclosureService $vulnerabilityDisclosureServiceSecurity $security)
  38.     {
  39.         $this->aboutUsService $aboutUsService;
  40.         $this->recaptchaService $recaptchaService;
  41.         $this->vulnerabilityDisclosureService $vulnerabilityDisclosureService;
  42.         $this->security $security;
  43.     }
  44.     /**
  45.      * @Route("/about", name="about_homepage", methods={"GET"})
  46.      * @Route("/about/", name="about_homepage_slash", methods={"GET"})
  47.      * @Route("/aboutus", name="aboutus_homepage", methods={"GET"})
  48.      * @Route("/aboutus/", name="aboutus_homepage_slash", methods={"GET"})
  49.      * @return Response
  50.      */
  51.     public function aboutUsAction()
  52.     {
  53.         $adminUrl null;
  54.         if ($this->security->isGranted(SecurityConstants::ROLE_ADMINISTRATOR)) {
  55.             $adminUrl $this->generateUrl('admin_app_aboutuswhoweare_edit', ['id' => 1]);
  56.         }
  57.         $whoWeAre $this->aboutUsService->getWhoWeAre();
  58.         $keyFacts $this->aboutUsService->getKeyFacts();
  59.         $OurTeam $this->aboutUsService->getOurTeam();
  60.         return $this->render('aboutus/aboutus.html.twig', [
  61.             'whoWeAre' => $whoWeAre,
  62.             'keyFacts' => $keyFacts,
  63.             'OurTeam' => $OurTeam,
  64.             'key' => $this->getParameter('google_maps_key'),
  65.             BaseController::PARAM_ADMIN_URL => $adminUrl
  66.         ]);
  67.     }
  68.     /**
  69.      * @Route("/about/whoweare", name="aboutus_whoweare", methods={"GET"})
  70.      * @Route("/about/whoweare/", name="aboutus_whoweare_slash", methods={"GET"})
  71.      * @return Response
  72.      */
  73.     public function aboutUsWhoWeAreAction()
  74.     {
  75.         $adminUrl null;
  76.         if ($this->security->isGranted(SecurityConstants::ROLE_ADMINISTRATOR)) {
  77.             $adminUrl $this->generateUrl('admin_app_aboutuswhoweare_edit', ['id' => 1]);
  78.         }
  79.         $whoWeAre $this->aboutUsService->getWhoWeAre();
  80.         return $this->render('aboutus/aboutus_who_we_are.html.twig', [
  81.             'form' => $whoWeAre,
  82.             BaseController::PARAM_ADMIN_URL => $adminUrl
  83.         ]);
  84.     }
  85.     /**
  86.      * @Route("/about/keyfacts", name="aboutus_keyfacts", methods={"GET"})
  87.      * @return Response
  88.      */
  89.     public function aboutUsKeyFactsAction()
  90.     {
  91.         $adminUrl null;
  92.         if ($this->security->isGranted(SecurityConstants::ROLE_ADMINISTRATOR)) {
  93.             $adminUrl $this->generateUrl('admin_app_aboutuskeyfacts_edit', ['id' => 1]);
  94.         }
  95.         $keyFacts $this->aboutUsService->getKeyFacts();
  96.         return $this->render('aboutus/aboutus_keyfacts.html.twig', [
  97.             'form' => $keyFacts,
  98.             BaseController::PARAM_ADMIN_URL => $adminUrl
  99.         ]);
  100.     }
  101.     /**
  102.      * @Route("/about/ourteam", name="aboutus_ourteam", methods={"GET"})
  103.      * @return Response
  104.      */
  105.     public function aboutUsOurTeamAction()
  106.     {
  107.         $adminUrl null;
  108.         if ($this->security->isGranted(SecurityConstants::ROLE_ADMINISTRATOR)) {
  109.             $adminUrl $this->generateUrl('admin_app_aboutusourteam_edit', ['id' => 1]);
  110.         }
  111.         $OurTeam $this->aboutUsService->getOurTeam();
  112.         return $this->render('aboutus/aboutus_ourteam.html.twig', [
  113.             'form' => $OurTeam,
  114.             BaseController::PARAM_ADMIN_URL => $adminUrl,
  115.             'key' => $this->getParameter('google_maps_key')
  116.         ]);
  117.     }
  118.     /**
  119.      * @Route("/about/contactus", name="aboutus_contactus", methods={"GET", "POST"})
  120.      * @param Request $request
  121.      * @return Response
  122.      */
  123.     public function aboutUsContactUsAction(Request $request)
  124.     {
  125.         $adminUrl null;
  126.         if ($this->security->isGranted(SecurityConstants::ROLE_ADMINISTRATOR)) {
  127.             $adminUrl $this->generateUrl('admin_app_aboutuscontactus_edit', ['id' => 1]);
  128.         }
  129.         $contactUsPage $this->aboutUsService->getContactUs();
  130.         $contactUs = new ContactUs();
  131.         $contactForm $this->createForm(ContactUsType::class, $contactUs);
  132.         $contactForm->handleRequest($request);
  133.         if ($contactForm->isSubmitted() && $contactForm->isValid()) {
  134.             if ($this->recaptchaService->captchaVerification($request->get('g-recaptcha-response'))) {
  135.                 $this->aboutUsService->sendMailContactUs($contactUs);
  136.                 $this->addFlash('about_us_success', ['title' => 'Thank You for Reaching Out!''message' => 'We appreciate you getting in touch with us. Your message has been successfully received, and our team is already reviewing it. We’ll respond to your inquiry or concern as soon as possible.']);
  137.             } else {
  138.                 $this->addFlash('about_us_error', ['title' => 'A Problem occured!''message' => 'An error occurred while processing your request.']);
  139.             }
  140.         }
  141.         return $this->render('aboutus/aboutus_contactus.html.twig', [
  142.             'form' => $contactUsPage,
  143.             'contactform' => $contactForm->createView(),
  144.             BaseController::PARAM_ADMIN_URL => $adminUrl,
  145.             'key' => $this->getParameter('google_maps_key')
  146.         ]);
  147.     }
  148.     /**
  149.      * @Route("/about/help", name="aboutus_help", methods={"GET", "POST"})
  150.      * @param Request $request
  151.      * @return Response
  152.      */
  153.     public function aboutUsHelpAction(Request $request)
  154.     {
  155.         $adminUrl null;
  156.         if ($this->security->isGranted(SecurityConstants::ROLE_ADMINISTRATOR)) {
  157.             $adminUrl $this->generateUrl('admin_app_aboutushelp_edit', ['id' => 1]);
  158.         }
  159.         $helps $this->aboutUsService->getHelps();
  160.         return $this->render('aboutus/aboutus_help.html.twig', [
  161.             'form' => $helps,
  162.             BaseController::PARAM_ADMIN_URL => $adminUrl
  163.         ]);
  164.     }
  165.     /**
  166.      * @Route("/about/terms", name="about_terms", methods={"GET"})
  167.      * @return Response
  168.      */
  169.     public function aboutTermsAction()
  170.     {
  171.         $adminUrl null;
  172.         if ($this->security->isGranted(SecurityConstants::ROLE_ADMINISTRATOR)) {
  173.             $adminUrl $this->generateUrl('admin_app_aboutterms_edit', ['id' => 1]);
  174.         }
  175.         $terms $this->aboutUsService->getTerms();
  176.         return $this->render('aboutus/about_terms.html.twig', [
  177.             'form' => $terms,
  178.             BaseController::PARAM_ADMIN_URL => $adminUrl
  179.         ]);
  180.     }
  181.     /**
  182.      * @Route("/about/data-privacy", name="about_data_privacy", methods={"GET"})
  183.      * @Route("/about/data-privacy/", name="about_data_privacy_slash", methods={"GET"})
  184.      * @return Response
  185.      */
  186.     public function aboutDataPrivacyAction()
  187.     {
  188.         return $this->render('aboutus/about_data_privacy.html.twig');
  189.     }
  190.     /**
  191.      * @Route("/about/privacy", name="about_privacy", methods={"GET"})
  192.      * @Route("/about/privacy-notice", name="about_privacy_notice", methods={"GET"})
  193.      * @return Response
  194.      */
  195.     public function aboutPrivacyAction()
  196.     {
  197.         $adminUrl null;
  198.         if ($this->security->isGranted(SecurityConstants::ROLE_ADMINISTRATOR)) {
  199.             $adminUrl $this->generateUrl('admin_app_aboutprivacy_edit', ['id' => 1]);
  200.         }
  201.         $terms $this->aboutUsService->getPrivacy();
  202.         return $this->render('aboutus/about_privacy.html.twig', [
  203.             'form' => $terms,
  204.             'noVideo' => "true",
  205.             BaseController::PARAM_ADMIN_URL => $adminUrl
  206.         ]);
  207.     }
  208.     /**
  209.      * @Route("/about/privacy/cookies", name="about_privacy_cookies", methods={"GET"})
  210.      * @Route("/about/privacy-notice/cookies", name="about_privacy_notice_cookies", methods={"GET"})
  211.      * @return Response
  212.      */
  213.     public function aboutPrivacyCookiesAction()
  214.     {
  215.         return $this->render('aboutus/about_privacy_cookies.html.twig');
  216.     }
  217.     /**
  218.      * @Route("/about/privacy/data-subject", name="about_privacy_data_subject", methods={"GET"})
  219.      * @Route("/about/privacy/data-subject/", name="about_privacy_data_subject_slash", methods={"GET"})
  220.      * @return Response
  221.      */
  222.     public function aboutPrivacyDataSubjectAction()
  223.     {
  224.         return $this->render('aboutus/about_privacy_data_subject.html.twig');
  225.     }
  226.     /**
  227.      * @Route("/about/privacy/data-subject/access-request", name="about_privacy_data_subject_access_request", methods={"GET", "POST"})
  228.      * @Route("/about/privacy/data-subject/access-request/", name="about_privacy_data_subject_access_request_slash", methods={"GET", "POST"})
  229.      * @return Response
  230.      */
  231.     public function aboutPrivacyDataSubjectAccessRequestAction(Request $request)
  232.     {
  233.         $dataRequestAccess = new DataSubjectAccessRequest();
  234.         $dataRequestAccessForm $this->createForm(DataSubjectAccessRequestType::class, $dataRequestAccess);
  235.         $dataRequestAccessForm->handleRequest($request);
  236.         if ($dataRequestAccessForm->isSubmitted() && $dataRequestAccessForm->isValid()) {
  237.             if ($this->recaptchaService->captchaVerification($request->get('g-recaptcha-response'))) {
  238.                 $this->aboutUsService->sendMailDSAR($dataRequestAccess);
  239.                 $this->addFlash('data_subject_access_success', ['title' => 'Thank You for Reaching Out!''message' => 'We appreciate you getting in touch with us. Your message has been successfully received, and our team is already reviewing it. We’ll respond to your inquiry or concern as soon as possible.']);
  240.             } else {
  241.                 $this->addFlash('data_subject_access_error', ['title' => 'A Problem occured!''message' => 'An error occurred while processing your request.']);
  242.             }
  243.         }
  244.         return $this->render('aboutus/about_privacy_data_subject_access_request.html.twig', [
  245.             'form' => $dataRequestAccessForm->createView(),
  246.             'key' => $this->getParameter('google_maps_key')
  247.         ]);
  248.     }
  249.     /**
  250.      * @Route("/about/vulnerability-disclosure", name="about_vulnerability_disclosure", methods={"GET"})
  251.      * @param Request|null $request
  252.      * @return Response
  253.      */
  254.     public function aboutVulnerabilityDisclosureAction(Request $request null)
  255.     {
  256.         // Build the form
  257.         $vulnerabilityForm = new VulnerabilityDisclosure();
  258.         $form $this->createForm(VulnerabilityDisclosureType::class, $vulnerabilityForm);
  259.         $form->handleRequest($request);
  260.         return $this->render(
  261.             'aboutus/about_vulnerability_disclosure.html.twig',
  262.             [
  263.                 'form' => $form->createView()
  264.             ]
  265.         );
  266.     }
  267.     /**
  268.      * @Route("/about/vulnerability-disclosure/submit", name="about_vulnerability_disclosure_submit", options={"expose" = true})
  269.      * @param Request $request
  270.      * @param LoggerInterface $logger
  271.      * @return Response
  272.      */
  273.     public function submitVulnerabilityDisclosureAction(Request $requestLoggerInterface $logger)
  274.     {
  275.         try {
  276.             $vulnerability = new VulnerabilityDisclosure();
  277.             $form $this->createForm(VulnerabilityDisclosureType::class, $vulnerability);
  278.             $form->handleRequest($request);
  279.             if (!$form->isValid()) {
  280.                 $errors Helper::getErrorMessagesFlat($formtrue);
  281.                 $data['message'] = "Please, check errors in vulnerability diclosure form.";
  282.                 $data['errors'] = $errors;
  283.                 $jsonResponse $this->json($dataJsonResponse::HTTP_BAD_REQUEST);
  284.                 return $jsonResponse;
  285.             }
  286.             if ($this->recaptchaService->captchaVerification($request->get('g-recaptcha-response'))) {
  287.                 $result $this->vulnerabilityDisclosureService->sendVulnerabilityDisclosure($vulnerability);
  288.                 if ($result->isError()) {
  289.                     return $this->json($result->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
  290.                 }
  291.                 return $this->json($result->getData());
  292.             }
  293.         } catch (Exception $ex) {
  294.             $logger->alert("error in submit vulnerability disclosure form" $ex->getMessage(), ["exception" => $ex]);
  295.             return $this->json($ex->getMessage(), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
  296.         }
  297.     }
  298.     /**
  299.      * @Route("/about/ethics", name="about_ethics", methods={"GET"})
  300.      * @return Response
  301.      */
  302.     public function aboutEthicsAction()
  303.     {
  304.         return $this->render('aboutus/about_ethics.html.twig');
  305.     }
  306.     /**
  307.      * @Route("/about/esg", name="about_esg", methods={"GET"})
  308.      * @return Response
  309.      */
  310.     public function aboutEsgAction()
  311.     {
  312.         return $this->render('aboutus/about_esg.html.twig');
  313.     }
  314.     /**
  315.      * @Route("/about/compliance", name="about_compliance", methods={"GET"})
  316.      * @return Response
  317.      */
  318.     public function aboutComplianceAction()
  319.     {
  320.         return $this->render('aboutus/about_compliance.html.twig');
  321.     }
  322. }