src/Controller/PageController.php line 319

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\AboutHim;
  4. use App\Entity\AboutMuseum;
  5. use App\Entity\Authors;
  6. use App\Entity\Comments;
  7. use App\Entity\Contact;
  8. use App\Entity\Creations;
  9. use App\Entity\Discuss;
  10. use App\Entity\HomePage;
  11. use App\Entity\Impact;
  12. use App\Entity\Interesting;
  13. use App\Entity\LastCreations;
  14. use App\Entity\Museum;
  15. use App\Entity\NewCreations;
  16. use App\Entity\NewImpact;
  17. use App\Entity\NewOptionAuthors;
  18. use App\Entity\OptionAuthors;
  19. use App\Entity\OurNotebooks;
  20. use App\Entity\Page;
  21. use App\Entity\Sayings;
  22. use App\Form\Type\CollapseType;
  23. use App\Form\Type\CollapseTypeFirst;
  24. use App\Repository\PageRepository;
  25. use App\Service\MailerService;
  26. use App\Service\UuidService;
  27. use Monolog\Handler\SwiftMailerHandler;
  28. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  29. use Symfony\Component\HttpFoundation\JsonResponse;
  30. use Symfony\Component\HttpFoundation\Response;
  31. use Symfony\Component\Routing\Annotation\Route;
  32. use Twig\Environment;
  33. use Knp\Component\Pager\PaginatorInterface;
  34. use Symfony\Component\HttpFoundation\Request;
  35. class PageController extends AbstractController
  36. {
  37.     /**
  38.      * @var PageRepository
  39.      */
  40.     private $pageRepository;
  41.     /**
  42.      * PageController constructor.
  43.      * @param PageRepository $pageRepository
  44.      */
  45.     public function __construct(PageRepository $pageRepository)
  46.     {
  47.         $this->pageRepository $pageRepository;
  48.     }
  49.     public function footer()
  50.     {
  51.         $em $this->getDoctrine();
  52.         $contact $em->getRepository(Contact::class)->findAll();
  53.         return $this->render('parts/footer.html.twig', [
  54.             'contact' => $contact[0],
  55.         ]);
  56.     }
  57.     /**
  58.      * @Route("/", name="page_index")
  59.      */
  60.     public function index()
  61.     {
  62.         $em $this->getDoctrine()->getManager();
  63.         $homePage $em->getRepository(HomePage::class)->findAll();
  64.         $authors $em->getRepository(Authors::class)->createQueryBuilder('a')
  65.             ->orderBy('a.orderId''ASC')
  66.             ->getQuery()
  67.             ->setMaxResults(4)
  68.             ->getResult();
  69.         $page $em->getRepository(Page::class)->find(1);
  70.         return $this->render('page/index.html.twig', [
  71.             'homePage' => $homePage[0],
  72.             'authors' => $authors,
  73.             'page' => $page,
  74.         ]);
  75.     }
  76.     /**
  77.      * @Route("/view/{slug}", name="page_view")
  78.      */
  79.     public function view($slug)
  80.     {
  81.         $em $this->getDoctrine()->getManager();
  82.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  83.         $page $em->getRepository(Page::class)->find(5);
  84.         return $this->render('page/view.html.twig', [
  85.             'item' => $authors,
  86.             'page' => $page
  87.         ]);
  88.     }
  89.     /**
  90.      * @Route("/options/{slug}", name="page_options")
  91.      */
  92.     public function options($slug)
  93.     {
  94.         $em $this->getDoctrine()->getManager();
  95.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  96.         $optionAuthors $em->getRepository(OptionAuthors::class)->findOneBy(['authors' => $authors]);
  97.         $option $em->getRepository(NewOptionAuthors::class)->findOneBy(['authors' => $authors]);
  98.         $page $em->getRepository(Page::class)->find(6);
  99.         return $this->render('page/options.html.twig', [
  100.             'item' => $authors,
  101.             'optionAuthors' => $optionAuthors,
  102.             'option' => $option,
  103.             'page' => $page,
  104.         ]);
  105.     }
  106.     /**
  107.      * @Route("/authors", name="page_authors")
  108.      */
  109.     public function authors(PaginatorInterface $paginatorRequest $request)
  110.     {
  111.         $em $this->getDoctrine()->getManager();
  112.         $authors $em->getRepository(Authors::class)->createQueryBuilder('a')
  113.             ->orderBy('a.orderId''ASC')
  114.             ->getQuery()
  115.             ->getResult();
  116.         $appointments $paginator->paginate(
  117.             $authors,
  118.             $request->query->getInt('page'1),
  119.             10
  120.         );
  121.         $page $em->getRepository(Page::class)->find(2);
  122.         return $this->render('page/authors.html.twig', [
  123.             'authors' => $authors,
  124.             'appointments' => $appointments,
  125.             'page' => $page
  126.         ]);
  127.     }
  128.     /**
  129.      * @Route("/search", name="get_search")
  130.      */
  131.     public function search(Request $request)
  132.     {
  133.         $em $this->getDoctrine()->getManager();
  134.         $authors $em->getRepository(Authors::class)->createQueryBuilder('a');
  135.         $creat $em->getRepository(LastCreations::class)->createQueryBuilder('nc');
  136.         $opt $em->getRepository(NewOptionAuthors::class)->createQueryBuilder('op');
  137.         $say $em->getRepository(Sayings::class)->createQueryBuilder('say');
  138.         $int $em->getRepository(Interesting::class)->createQueryBuilder('int');
  139.         $imp $em->getRepository(NewImpact::class)->createQueryBuilder('imp');
  140.         $abou $em->getRepository(AboutHim::class)->createQueryBuilder('abou');
  141.         $mus $em->getRepository(Museum::class)->createQueryBuilder('mus');
  142.         if ($request->get('search') && !empty($request->get('search'))) {
  143.             $allData = [];
  144.             $authors
  145.                 ->select('a.id as authors_id')
  146.                 ->where('a.fullName LIKE :search Or a.titleText LIKE :search Or a.shortText LIKE :search Or a.question LIKE :search Or a.bottomPartBoldText LIKE :search')
  147.                 ->setParameter('search''%' $request->get('search') . '%');
  148.             $authors_information $authors->getQuery()->getResult();
  149.             if (!empty($authors_information)) {
  150.                 $allData['authors'] = $authors_information;
  151.             }
  152.             $creat
  153.                 ->select('nc.id as new_creations_id')
  154.                 ->Where('nc.collection  LIKE :search Or nc.title LIKE :search ')
  155.                 ->setParameter('search''%' $request->get('search') . '%');
  156.             $new_creations_information $creat->getQuery()->getResult();
  157.             if (!empty($new_creations_information)) {
  158.                 $allData['creations'] = $new_creations_information;
  159.             }
  160.             $opt
  161.                 ->select('op.id as new_options_id')
  162.                 ->Where('op.collection LIKE :search')
  163.                 ->setParameter('search''%' $request->get('search') . '%');
  164.             $new_options $opt->getQuery()->getResult();
  165.             if (!empty($new_options)) {
  166.                 $allData['options'] = $new_options;
  167.             }
  168.             $say
  169.                 ->select('say.id as new_sayings_id')
  170.                 ->Where('say.text LIKE :search Or say.bottomText LIKE :search')
  171.                 ->setParameter('search''%' $request->get('search') . '%');
  172.             $new_sayings $say->getQuery()->getResult();
  173.             if (!empty($new_sayings)) {
  174.                 $allData['sayings'] = $new_sayings;
  175.             }
  176.             $int
  177.                 ->select('int.id as new_interesting_id')
  178.                 ->Where('int.rightText LIKE :search Or int.text LIKE :search')
  179.                 ->setParameter('search''%' $request->get('search') . '%');
  180.             $new_interesting $int->getQuery()->getResult();
  181.             if (!empty($new_interesting)) {
  182.                 $allData['interesting'] = $new_interesting;
  183.             }
  184.             $imp
  185.                 ->select('imp.id as new_impact_id')
  186.                 ->Where('imp.collection LIKE :search')
  187.                 ->setParameter('search''%' $request->get('search') . '%');
  188.             $new_impact $imp->getQuery()->getResult();
  189.             if (!empty($new_impact)) {
  190.                 $allData['impact'] = $new_impact;
  191.             }
  192.             $imp
  193.                 ->select('imp.id as new_impact_id')
  194.                 ->Where('imp.collection LIKE :search')
  195.                 ->setParameter('search''%' $request->get('search') . '%');
  196.             $new_impact $imp->getQuery()->getResult();
  197.             if (!empty($new_impact)) {
  198.                 $allData['impact'] = $new_impact;
  199.             }
  200.             $abou
  201.                 ->select('abou.id as new_about_id')
  202.                 ->Where('abou.rightPart LIKE :search Or abou.BottomPart LIKE :search')
  203.                 ->setParameter('search''%' $request->get('search') . '%');
  204.             $new_about $abou->getQuery()->getResult();
  205.             if (!empty($new_about)) {
  206.                 $allData['about'] = $new_about;
  207.             }
  208.             $mus
  209.                 ->select('mus.id as new_museum_id')
  210.                 ->Where('mus.museum LIKE :search')
  211.                 ->setParameter('search''%' $request->get('search') . '%');
  212.             $new_museum $mus->getQuery()->getResult();
  213.             if (!empty($new_museum)) {
  214.                 $allData['museum'] = $new_museum;
  215.             }
  216.         }
  217.         $author = [];
  218.         $creation = [];
  219.         $options = [];
  220.         $sayings = [];
  221.         $interesting = [];
  222.         $impact = [];
  223.         $about = [];
  224.         $museum = [];
  225.         foreach ($allData as $items) {
  226.             foreach ($items as $item) {
  227.                 foreach ($item as $key => $value) {
  228.                     if ($key == "authors_id") {
  229.                         $aut[] = $em->getRepository(Authors::class)->findBy(['id' => $value]);
  230.                         $author $aut;
  231.                     } elseif ($key == "new_creations_id") {
  232.                         $crea[] = $em->getRepository(LastCreations::class)->findBy(['id' => $value]);
  233.                         $creation $crea;
  234.                     } elseif ($key == "new_options_id") {
  235.                         $op[] = $em->getRepository(NewOptionAuthors::class)->findBy(['id' => $value]);
  236.                         $options $op;
  237.                     } elseif ($key == "new_sayings_id") {
  238.                         $sa[] = $em->getRepository(Sayings::class)->findBy(['id' => $value]);
  239.                         $sayings $sa;
  240.                     } elseif ($key == "new_interesting_id") {
  241.                         $in[] = $em->getRepository(Interesting::class)->findBy(['id' => $value]);
  242.                         $interesting $in;
  243.                     } elseif ($key == "new_impact_id") {
  244.                         $im[] = $em->getRepository(NewImpact::class)->findBy(['id' => $value]);
  245.                         $impact $im;
  246.                     } elseif ($key == "new_about_id") {
  247.                         $ab[] = $em->getRepository(AboutHim::class)->findBy(['id' => $value]);
  248.                         $about $ab;
  249.                     } elseif ($key == "new_museum_id") {
  250.                         $muse[] = $em->getRepository(Museum::class)->findBy(['id' => $value]);
  251.                         $museum $muse;
  252.                     }
  253.                 }
  254.             }
  255.         }
  256.         $page $em->getRepository(Page::class)->find(14);
  257.         return $this->render('parts/search.html.twig', [
  258.             'author' => $author,
  259.             'creations' => $creation,
  260.             'options' => $options,
  261.             'sayings' => $sayings,
  262.             'interesting' => $interesting,
  263.             'impact' => $impact,
  264.             'about' => $about,
  265.             'museum' => $museum,
  266.             'page' => $page,
  267.         ]);
  268.     }
  269.     /**
  270.      * @Route("/get_creation", name="get_creation")
  271.      */
  272.     public function getCreation(Request $request)
  273.     {
  274.         $em $this->getDoctrine()->getManager();
  275.         if ($request->get('item')) {
  276.             $title $request->get('item')["id"];
  277.             $slug $request->get('item')["slug"];
  278.             $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  279.             $creat $em->getRepository(LastCreations::class)->createQueryBuilder('n')
  280.                 ->where('n.authors = :author_id')
  281.                 ->setParameter('author_id'$authors->getId())
  282.                 ->getQuery()
  283.                 ->getArrayResult();
  284.             $newcreations $em->getRepository(LastCreations::class)->createQueryBuilder('c')
  285.                 ->where('c.authors = :author_id')
  286.                 ->andWhere('c.title=:tit')
  287.                 ->setParameter('author_id'$authors->getId())
  288.                 ->setParameter('tit'$title)
  289.                 ->getQuery()
  290.                 ->getArrayResult();
  291.             $newArr = [];
  292.             foreach ($newcreations as $item) {
  293.             }
  294.         }
  295.         return new JsonResponse($item['title']);
  296.     }
  297.     /**
  298.      * @Route("/creations/{slug}", name="page_creations")
  299.      */
  300.     public function creations($slug)
  301.     {
  302.         $em $this->getDoctrine()->getManager();
  303.         $comments $em->getRepository(Comments::class)->findAll();
  304.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  305.         $creations $em->getRepository(Creations::class)->createQueryBuilder('c')
  306.             ->where('c.authors = :author_id')
  307.             ->setParameter('author_id'$authors->getId())
  308.             ->getQuery()
  309.             ->getArrayResult();
  310.         $newcreations $em->getRepository(NewCreations::class)->createQueryBuilder('c')
  311.             ->where('c.authors = :author_id')
  312.             ->setParameter('author_id'$authors->getId())
  313.             ->getQuery()
  314.             ->getArrayResult();
  315.         $lastcreations $em->getRepository(LastCreations::class)->createQueryBuilder('c')
  316.             ->where('c.authors = :author_id')
  317.             ->setParameter('author_id'$authors->getId())
  318.             ->getQuery()
  319.             ->getArrayResult();
  320.         $page $em->getRepository(Page::class)->find(7);
  321.         return $this->render('page/creations.html.twig', [
  322.             'newcreations' => $newcreations,
  323.             'lastcreations' => $lastcreations,
  324.             'comments' => $comments,
  325.             'item' => $authors,
  326.             'page' => $page,
  327. //            'creations' => count($creations) ? $creations[0] : [],
  328.         ]);
  329.     }
  330.     /**
  331.      * @Route("/sayings/{slug}", name="page_sayings")
  332.      */
  333.     public function sayings($slug)
  334.     {
  335.         $em $this->getDoctrine()->getManager();
  336.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  337.         $sayings $em->getRepository(Sayings::class)->findOneBy(['authors' => $authors]);
  338.         $comments $em->getRepository(Comments::class);
  339.         $newData = [];
  340.         $page $em->getRepository(Page::class)->find(8);
  341.         return $this->render('page/sayings.html.twig', [
  342.             'sayings' => $sayings,
  343.             'item' => $authors,
  344.             'page' => $page,
  345.         ]);
  346.     }
  347.     /**
  348.      * @Route("/interesting/{slug}", name="page_interesting")
  349.      */
  350.     public function interesting($slug)
  351.     {
  352.         $em $this->getDoctrine()->getManager();
  353.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  354.         $interesting $em->getRepository(Interesting::class)->findOneBy(['authors' => $authors]);
  355.         $page $em->getRepository(Page::class)->find(9);
  356.         return $this->render('page/interesting.html.twig', [
  357.             'item' => $authors,
  358.             'interesting' => $interesting,
  359.             'page' => $page,
  360.         ]);
  361.     }
  362.     /**
  363.      * @Route("/about_him/{slug}", name="page_about_him")
  364.      */
  365.     public function about_him($slug)
  366.     {
  367.         $em $this->getDoctrine()->getManager();
  368.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  369.         $aboutHim $em->getRepository(AboutHim::class)->findOneBy(['authors' => $authors]);
  370.         $comments $em->getRepository(Comments::class);
  371.         $newData = [];
  372.         $page $em->getRepository(Page::class)->find(11);
  373.         return $this->render('page/about_him.html.twig', [
  374.             'item' => $authors,
  375.             'aboutHim' => $aboutHim,
  376.             'comments' => $newData,
  377.             'page' => $page,
  378.         ]);
  379.     }
  380.     /**
  381.      * @Route("/impact/{slug}", name="page_impact")
  382.      */
  383.     public function impact($slug)
  384.     {
  385.         $em $this->getDoctrine()->getManager();
  386.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  387.         $impact $em->getRepository(Impact::class)->findOneBy(['authors' => $authors]);
  388.         $comments $em->getRepository(Comments::class);
  389.         $newImpact $em->getRepository(NewImpact::class)->findOneBy(['authors' => $authors]);
  390.         if (isset($newImpact)) {
  391.             $new $newImpact->getCollection();
  392.         } else {
  393.             $new $newImpact;
  394.         }
  395.         $page $em->getRepository(Page::class)->find(10);
  396.         return $this->render('page/impact.html.twig', [
  397.             'item' => $authors,
  398.             'impact' => $impact,
  399.             'newImpact' => $new,
  400.             'page' => $page,
  401.         ]);
  402.     }
  403.     /**
  404.      * @Route("/museum/{slug}", name="page_museum")
  405.      */
  406.     public function museum($slug)
  407.     {
  408.         $em $this->getDoctrine()->getManager();
  409.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  410.         $museum $em->getRepository(Museum::class)->findOneBy(['authors' => $authors]);
  411.         $page $em->getRepository(Page::class)->find(12);
  412.         return $this->render('page/museum.html.twig', [
  413.             'item' => $authors,
  414.             'museum' => $museum,
  415.             'page' => $page,
  416.         ]);
  417.     }
  418.     /**
  419.      * @Route("/about_museum/{slug}", name="page_about_museum")
  420.      */
  421.     public function about_museum($slug)
  422.     {
  423.         $em $this->getDoctrine()->getManager();
  424.         $authors $em->getRepository(Authors::class)->findOneBy(['slug' => $slug]);
  425.         $aboutMuseum $em->getRepository(AboutMuseum::class)->findOneBy(['authors' => $authors]);
  426.         return $this->render('page/about-museum.html.twig', [
  427.             'item' => $authors,
  428.             'aboutMuseum' => $aboutMuseum
  429.         ]);
  430.     }
  431.     /**
  432.      * @Route("/discuss/{slug}", name="page_discuss")
  433.      */
  434.     public function discuss($slug)
  435.     {
  436.         $em $this->getDoctrine()->getManager();
  437.         $comment $em->getRepository(Comments::class)->findOneBy(['id' => $slug]);
  438.         $discuss $em->getRepository(Discuss::class)->findBy(['comments' => $slug], ['orderId' => 'DESC']);
  439.         $comments $em->getRepository(Discuss::class)->CreateQueryBuilder('c')
  440.             ->where('c.comments =:id')
  441.             ->setParameter('id'$slug)
  442.             ->getQuery()
  443.             ->getArrayResult();
  444.         $page $em->getRepository(Page::class)->find(13);
  445.         return $this->render('page/discuss.html.twig', [
  446.             'comment' => $comment,
  447.             'answer' => $comments,
  448.             'discuss' => $discuss,
  449.             'page' => $page,
  450.         ]);
  451.     }
  452.     /**
  453.      * @Route("/basket", name="page_basket")
  454.      */
  455.     public function basket()
  456.     {
  457.         $em $this->getDoctrine()->getManager();
  458.         $page $em->getRepository(Page::class)->find(4);
  459.         return $this->render('page/basket.html.twig', [
  460.             'page' => $page
  461.         ]);
  462.     }
  463.     /**
  464.      * @Route("/notebooks", name="page_notebooks")
  465.      */
  466.     public function notebooks()
  467.     {
  468.         $em $this->getDoctrine()->getManager();
  469.         $homePage $em->getRepository(HomePage::class)->findAll();
  470.         $notebooks $em->getRepository(OurNotebooks::class)->findAll();
  471.         $page $em->getRepository(Page::class)->find(3);
  472.         return $this->render('page/our_notebooks.html.twig', [
  473.             'homePage' => $homePage[0],
  474.             'notebooks' => $notebooks,
  475.             'page' => $page,
  476.         ]);
  477.     }
  478. }