src/Controller/IndexController.php line 48

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Instagram\Feed;
  4. use App\Service\DataFetcher;
  5. use Symfony\Component\HttpFoundation\RedirectResponse;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  9. class IndexController extends Controller
  10. {
  11.     public function index(DataFetcher $dataFetcherFeed $feed): Response
  12.     {
  13.         // ig id nomo: 45908777985
  14.         $instagramPosts $feed->getPosts();
  15.         $configuration $this->dataFetcher->getConfig();
  16.         $results $dataFetcher->getBlogPosts(1);
  17.         $realisations $dataFetcher->getRealisationsByCategories();
  18.         return $this->render('main.html.twig',
  19.             [
  20.                 'configuration' => $configuration,
  21.                 'realisations' => $realisations,
  22.                 'instagramPosts' => $instagramPosts,
  23.                 'blogPosts' => $results,
  24.             ]
  25.         );
  26.     }
  27.     public function about(DataFetcher $dataFetcher): Response
  28.     {
  29.         $page $dataFetcher->getPage('o-nomo');
  30.         $realisations $dataFetcher->getRealisationsByCategories();
  31.         return $this->render(
  32.             'about.html.twig',
  33.             [
  34.                 'page' => $page,
  35.                 'realisations' => $realisations,
  36.             ]
  37.         );
  38.     }
  39.     public function offer(DataFetcher $dataFetcher): Response
  40.     {
  41.         $page $dataFetcher->getPage('oferta');
  42.         $realisations $dataFetcher->getRealisationsByCategories();
  43.         return $this->render(
  44.             'offer.html.twig',
  45.             [
  46.                 'page' => $page,
  47.                 'realisations' => $realisations,
  48.             ]
  49.         );
  50.     }
  51.     public function blog(DataFetcher $dataFetcherRequest $requestUrlGeneratorInterface $generator): Response
  52.     {
  53.         if (null === $request->query->get('sort')) {
  54.             return new RedirectResponse($generator->generate('blog') . '?sort=asc');
  55.         }
  56.         $filters $this->parseFilters($request);
  57.         $page max((int) $request->get('page'1), 1);
  58.         $results $dataFetcher->getBlogPostsFiltered($filters$page9);
  59.         $pages $dataFetcher->getBlogPostsPagesNumberFiltered($filters9);
  60.         $blogPostsCount $dataFetcher->getBlogPostsCountFiltered($filters);
  61.         return $this->render(
  62.             'blog.html.twig',
  63.             [
  64.                 'pages' => $pages,
  65.                 'blogPosts' => $results,
  66.                 'blogPosts_count' => $blogPostsCount,
  67.                 'categoriesList' => $dataFetcher->categoryList('blog_post''b'),
  68.                 'archivesList' => $dataFetcher->getArchiveYears('blog_post''b'),
  69.             ]
  70.         );
  71.     }
  72.     public function portfolio(DataFetcher $dataFetcherRequest $requestUrlGeneratorInterface $generator): Response
  73.     {
  74.         if (null === $request->query->get('sort')) {
  75.             return new RedirectResponse($generator->generate('portfolio') . '?sort=ord');
  76.         }
  77.         $filters $this->parseFilters($request);
  78.         $page max((int) $request->get('page'1), 1);
  79.         $results $dataFetcher->getRealisationsFiltered($filters$page9);
  80.         $pages $dataFetcher->getRealisationsPagesNumberFiltered($filters9);
  81.         $realisationsCount $dataFetcher->getRealisationsCountFiltered($filters);
  82.         return $this->render(
  83.             'portfolios.html.twig',
  84.             [
  85.                 'pages' => $pages,
  86.                 'realisations' => $results,
  87.                 'realisation_count' => $realisationsCount,
  88.                 'categoriesList' => $dataFetcher->categoryList('article''a'),
  89.                 'archivesList' => $dataFetcher->getArchiveYears('article''a'),
  90.             ]
  91.         );
  92.     }
  93. }