src/Controller/MainController.php line 51

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Antony Tkachenko <at@canaryknight.ru>
  4.  */
  5. namespace App\Controller;
  6. use App\Entity\BlogTag;
  7. use App\Entity\ModulePage;
  8. use App\Helper\LastModifyHelper;
  9. use App\Repository\BlogPostRepository;
  10. use App\Repository\ModulePageRepository;
  11. use App\Repository\ReviewRepository;
  12. use App\Services\WalletRedirect\WalletRedirectService;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\HttpKernel\KernelInterface;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. class MainController extends AbstractController
  18. {
  19.     /** @var WalletRedirectService */
  20.     private $walletRedirectService;
  21.     private LastModifyHelper $tracker;
  22.     public function __construct(WalletRedirectService $walletRedirectServiceKernelInterface $appKernel)
  23.     {
  24.         $this->walletRedirectService $walletRedirectService;
  25.         $this->tracker = new LastModifyHelper($appKernel);
  26.     }
  27.     /**
  28.      * @Route("/", name="home", methods={"GET"}, requirements={"_locale":"ru"})
  29.      */
  30.     public function index(
  31.         ReviewRepository $reviewRepository,
  32.         BlogPostRepository $blogPostRepository
  33.     ): Response
  34.     {
  35.         $reviews $reviewRepository->findAllOrdered();
  36.         $query $blogPostRepository->onlyPublishedSelective();
  37.         $posts $query->getQuery()->getResult();
  38.         $template 'main/index.html.twig';
  39.         $modified $this->tracker->get($template);
  40.         $response $this->render($template, [
  41.             'reviews' => $reviews,
  42.             'posts' => $posts,
  43.             'modified' => $modified,
  44.         ]);
  45.         $response->headers->set('Last-Modified'$modified);
  46.         return $response;
  47.     }
  48.     /**
  49.      * @Route("/tariff", name="tariff.ru", methods={"GET"}, requirements={"_locale":"ru"})
  50.      */
  51.     public function tariff(): Response
  52.     {
  53.         $redirectRoute $this->walletRedirectService->getWalletTariffRouteName();
  54.         if ($redirectRoute){
  55.             return $this->redirectToRoute($redirectRoute);
  56.         }
  57.         $template 'main/tariff.html.twig';
  58.         $modified $this->tracker->get($template);
  59.         $response $this->render($template, ['modified' => $modified]);
  60.         $response->headers->set('Last-Modified'$modified);
  61.         return $response;
  62.     }
  63.     /**
  64.      * @Route("/register", name="register", methods={"GET"})
  65.      */
  66.     public function register(): Response
  67.     {
  68.         $promo $this->walletRedirectService->checkSource(WalletRedirectService::SOURCE_GPB) ? "Газпромбанк" "";
  69.         $template 'main/register.html.twig';
  70.         $modified $this->tracker->get($template);
  71.         $response $this->render($template, ['promo' => $promo'modified' => $modified]);
  72.         $response->headers->set('Last-Modified'$modified);
  73.         return $response;
  74.     }
  75.     /**
  76.      * @Route("/sitemap", name="sitemap.page", methods={"GET"}, requirements={"_locale":"ru"})
  77.      */
  78.     public function mapPage(
  79.         BlogPostRepository $blogPostRepository,
  80.         ModulePageRepository $modulePageRepository
  81.     ): Response
  82.     {
  83.         $template 'main/sitemap.html.twig';
  84.         $modified $this->tracker->get($template);
  85.         $posts $blogPostRepository->onlyPublished()->getQuery()->getResult();
  86.         $pages $modulePageRepository->findAllForMenu();
  87.         $response $this->render(
  88.             $template, [
  89.             'modified' => $modified,
  90.             'posts' => $posts,
  91.             'pages' => $pages,
  92.         ]);
  93.         $response->headers->set('Last-Modified'$modified);
  94.         return $response;
  95.     }
  96.     /**
  97.      * @Route("/", name="home.en", methods={"GET"}, requirements={"_locale":"en"})
  98.      */
  99.     public function indexEn()
  100.     {
  101.         return $this->redirect('/wallet');
  102.     }
  103. }