src/Controller/FrontMyflix/FrontController.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Controller\FrontMyflix;
  3. use App\Controller\CoreController;
  4. use App\Entity\DefaultSetting;
  5. use App\Enum\Roles;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. /**
  11.  * Class FrontController
  12.  * @package App\Controller\FrontMyflix
  13.  * @Route("/")
  14.  */
  15. class FrontController extends CoreController
  16. {
  17.     /**
  18.      * Front myflix
  19.      *
  20.      * @return Response
  21.      *
  22.      * @Route("/", name="front_myflix")
  23.      */
  24.     public function index(): Response
  25.     {
  26.         $package $this->repository->PackageRepository->findBy(["status" => true "isDeleted" => false ],['createdAt' => 'asc'] , 3);
  27.         $percent $this->repository->DefaultSettingRepository->findAll();
  28.         $conversionRate $this->repository->ConversionRateRepository->findAll();
  29.         $get_conversion_rate = array();
  30.         $get_conversion_rate['count'] = 0;
  31.         foreach ($conversionRate as $rate){
  32.             $get_conversion_rate[$rate->getCurrency()] = $rate->getValue();
  33.             $get_conversion_rate['status'][$rate->getCurrency()] = $rate->getStatus();
  34.             if($rate->getStatus() == true) {
  35.                 $get_conversion_rate['count'] += 1;
  36.             }
  37.         }
  38.         $user $this->getUser(); $detail null;
  39.         if($user && $this->isGranted(Roles::ROLE_SUPER_PARTNER)){
  40.             $detail $this->repository->MemberPaymentDetailsRepository->findOneBy(['adminMyflix' => $user->getId(), 'statusPayment' => true],['id' => 'desc']);
  41.         }
  42.         return $this->render('front_myflix/index.html.twig', [
  43.             'packages' => $package,
  44.             'percent' => isset($percent[0]) ? $percent[0]->getPercentPackage() : 0,
  45.             'conversionRate' => $get_conversion_rate,
  46.             'detail' => $detail
  47.         ]);
  48.     }
  49.     /**
  50.      * Ask for demo
  51.      *
  52.      * @return Response
  53.      *
  54.      * @Route("/ask/demo", name="ask_for_demo")
  55.      */
  56.     public function askForDemo(): Response
  57.     {
  58.         /** send mail to partner */
  59.         $name $this->requestStack->getCurrentRequest()->get('name');
  60.         $email =  $this->requestStack->getCurrentRequest()->get('email');
  61.         $company =  $this->requestStack->getCurrentRequest()->get('company');
  62.         try{
  63.             $data_mess = [
  64.                 'name' => $name,
  65.                 'company' =>  $company,
  66.                 'email_' =>  $email,
  67.                 'LOGO_MYFLIX' => 'logo-login.png',
  68.                 'KEY_ICON' => 'key-icon.png'
  69.             ];
  70.             $locale $this->requestStack->getCurrentRequest()->getLocale();
  71.             $mailerSender $this->getParameter('mailer.support_email');
  72.             $template 'back/default/emails/notif_ask_demo_myflix.html.twig';
  73.             $subject $this->translator->trans('email.request_demo');
  74.     
  75.             $sendingMailOperation $this->mailer->send($mailerSender,
  76.                 trim($this->getParameter('mailer.form_email')),
  77.                 $template,
  78.                 $subject,
  79.                 null,
  80.                 $data_mess
  81.             );
  82.         }catch (\Exception $e){
  83.              return new Response('invalid');
  84.         }
  85.         return new Response('success');
  86.     }
  87.     /**
  88.      * Contact myflix
  89.      *
  90.      * @return Response
  91.      *
  92.      * @Route("/contact", name="contact_myflix")
  93.      */
  94.     public function contactMyflix(): Response
  95.     {
  96.         /** send mail to partner */
  97.         try{
  98.             $name $this->requestStack->getCurrentRequest()->get('name');;
  99.             $email $this->requestStack->getCurrentRequest()->get('email');;
  100.             $phone $this->requestStack->getCurrentRequest()->get('phone');;
  101.             $message $this->requestStack->getCurrentRequest()->get('message');;
  102.             $data_mess = [
  103.                 'name' => $name,
  104.                 'phone' =>  $phone,
  105.                 'email_' =>  $email,
  106.                 'message' =>  $message,
  107.                 'LOGO_MYFLIX' => 'logo-login.png',
  108.                 'KEY_ICON' => 'key-icon.png'
  109.             ];
  110.     
  111.             $mailerSender $this->getParameter('mailer.support_email');
  112.             $template 'back/default/emails/notif_contact_myflix.html.twig';
  113.             $subject $this->translator->trans('email.contact');
  114.     
  115.             $sendingMailOperation $this->mailer->send($mailerSender,
  116.                 trim($this->getParameter('mailer.form_email')),
  117.                 $template,
  118.                 $subject,
  119.                 null,
  120.                 $data_mess
  121.             );
  122.         }catch (\Exception $e){
  123.              return new Response('invalid');
  124.         }
  125.         return new Response('success');
  126.     }
  127.     /**
  128.      * Change locale - front
  129.      *
  130.      * @param $locale
  131.      * @return Response
  132.      *
  133.      * @Route("/change/locale/front/{locale}", name="change_locale_front")
  134.      */
  135.     public function changeLocale($locale): Response
  136.     {
  137.         // On stocke la langue dans la session
  138.         $this->requestStack->getCurrentRequest()->getSession()->set('_locale'$locale);
  139.         // On revient sur la page pr�c�dente
  140.         return $this->redirectToRoute('front_myflix' );
  141.     }
  142.     /**
  143.      * Change locale - front login
  144.      *
  145.      * @param $locale
  146.      * @return Response
  147.      *
  148.      * @Route("/change/locale/front/login/{locale}", name="change_locale_front_login")
  149.      */
  150.     public function changeLocaleLogin($locale): Response
  151.     {
  152.         // On stocke la langue dans la session
  153.         $this->requestStack->getCurrentRequest()->getSession()->set('_locale'$locale);
  154.         // On revient sur la page pr�c�dente
  155.         return $this->redirect($this->requestStack->getCurrentRequest()->headers->get('referer'));
  156.     }
  157.     /**
  158.      * Page 404
  159.      *
  160.      * @return Response
  161.      *
  162.      * @Route("/error/404", name="error_404")
  163.      */
  164.     public function page404() : Response
  165.     {
  166.         return $this->render('front/default/404.html.twig');
  167.     }
  168. }