src/AppBundle/Controller/DefaultController.php line 46

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Controller;
  3. use AppBundle\Entity\HomepageTile;
  4. use AppBundle\Entity\Page;
  5. use AppBundle\Service\BannerCarouselService;
  6. use AppBundle\Util\ChromeItemsHelperTrait;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  8. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  9. use Symfony\Bundle\FrameworkBundle\Translation\Translator;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. class DefaultController extends Controller
  13. {
  14.     use ChromeItemsHelperTrait;
  15.     /**
  16.      * @Route("/", name="index")
  17.      */
  18.     public function index(Request $requestBannerCarouselService $carouselServiceTranslator $translator)
  19.     {
  20.         $em $this->getDoctrine()->getManager();
  21.         $page $em->getRepository(Page::class)
  22.             ->findOneBy(['type' => Page::HOMEPAGE]);
  23.         if ($page === null) {
  24.             // in case if homepage is not specified in admin dashboard
  25.             return $this->render('AppBundle::index.html.twig');
  26.         }
  27.         $homepageTiles $em->getRepository(HomepageTile::class)
  28.             ->getSortedTiles();
  29.         $blockPosts $em->getRepository(Page::class)
  30.             ->getNewsPages();
  31.         $ctx = [
  32.             'page' => $page,
  33.             'homepageTiles' => $homepageTiles,
  34.             'blogPosts' => $blockPosts,
  35.         ];
  36.         $this->prepareItemsInController($request$page$em$translator$ctx);
  37.         return $this->render('AppBundle:Page:homepage.html.twig'$ctx);
  38.     }
  39.     /**
  40.      * @Route("/browse-resources/select", name="browse-resources")
  41.      */
  42.     public function browseResourcesAction()
  43.     {
  44.         $images $this->getDoctrine()
  45.             ->getRepository('AppBundle:File')
  46.             ->findImagesAndVideos();
  47.         return $this->render('@App/browse-images.html.twig', [
  48.             "images" => $images
  49.         ]);
  50.         $galleryStruct $this->getDoctrine()
  51.             ->getRepository('AppBundle:Gallery')
  52.             ->findAllFormatStructure();
  53.         $files $this->getDoctrine()
  54.             ->getRepository('AppBundle:File')
  55.             ->findAllAndFormatIt();
  56.         $videos $this->getDoctrine()
  57.             ->getRepository('AppBundle:Video')
  58.             ->findAllFormatStructure();
  59.         $audios $this->getDoctrine()
  60.             ->getRepository('AppBundle:Audio')
  61.             ->findAllFormatStructure();
  62.         $documents $this->getDoctrine()
  63.             ->getRepository('AppBundle:Document')
  64.             ->findAllFormatStructure();
  65.         $banners $this->getDoctrine()
  66.             ->getRepository('AppBundle:Media')
  67.             ->findAllFormatStructure();
  68.         $flipbook $this->getDoctrine()
  69.             ->getRepository('AppBundle:Flipbook')
  70.             ->findAllFormatStructure();
  71.         return $this->render('AppBundle:Form:ckeditor_widget.html.twig', [
  72.             'galleryStruct' => $galleryStruct,
  73.             'files' => $files,
  74.             'docs' => $documents,
  75.             'videos' => $videos,
  76.             'audios' => $audios,
  77.             'banners' => $banners,
  78.             'flipbook' => $flipbook,
  79.         ]);
  80.     }
  81.     /**
  82.      * @Route("/gallery/{id}", name="gallery")
  83.      */
  84.     public function galleryAction($id null)
  85.     {
  86.         $galleryId $id;
  87.         $files = [];
  88.         $repo $this->getDoctrine()->getRepository('AppBundle:Gallery');
  89.         $repoF $this->getDoctrine()->getRepository('AppBundle:File');
  90.         $gallery $repo->find($galleryId);
  91.         $structure $gallery->getStructure();
  92.         $current $structure['current'];
  93.         $filesId $structure['structure'][$current];
  94.         foreach ($filesId as $fid) {
  95.             $files[] = $repoF->find($fid);
  96.         }
  97.         return $this->render('AppBundle::gallery.html.twig', [
  98.             'gallery' => $gallery,
  99.             'files' => $files
  100.         ]);
  101.     }
  102.     /**
  103.      * @Route("/updatedb", name="update-database")
  104.      */
  105.     public function updateDbAction()
  106.     {
  107.         $dbUpdater $this->get('app.dbupdaterservice');
  108.         $dbUpdater->update();
  109.         return new Response('DB updated'Response::HTTP_OK);
  110.     }
  111.     /**
  112.      * @Route("/resources-to-files", name="resources-to-file")
  113.      */
  114.     public function resourcesToFile()
  115.     {
  116.     }
  117. }