src/Main/Controller/IndexController.php line 28

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Main\Controller;
  3. use App\Base\Controller\BaseController;
  4. use App\Content\Repository\Advantage\AdvantageRepository;
  5. use App\Content\Repository\Advantage\AdvantageSettingsRepository;
  6. use App\Content\Repository\ConstructionProgress\ConstructionProgressAlbumRepository;
  7. use App\Content\Repository\Hero\HeroSettingsRepository;
  8. use App\Content\Repository\Infrastructure\InfrastructureItemRepository;
  9. use App\Content\Repository\Infrastructure\InfrastructureSettingsRepository;
  10. use App\Content\Repository\Infrastructure\InfrastructureTypeRepository;
  11. use App\Content\Repository\PaymentRepository;
  12. use App\Content\Repository\Project\ProjectItemRepository;
  13. use App\Leads\Form\RecallType;
  14. use App\Main\Repository\PopupRepository;
  15. use App\Realty\Service\CountByRoomsGenerator;
  16. use App\Realty\Service\RealtyItemsViewMaker;
  17. use App\Realty\Entity\GenplanSettings;
  18. use App\Realty\Repository\GenplanSettingsRepository;
  19. use Symfony\Component\HttpFoundation\Request;
  20. use Symfony\Component\HttpFoundation\Response;
  21. use Symfony\Component\Routing\Annotation\Route;
  22. class IndexController extends BaseController
  23. {
  24.     #[Route(path'/'name'main:index'options: ['sitemap' => true])]
  25.     public function index(
  26.         Request $request,
  27.         HeroSettingsRepository $heroSettingsRepository,
  28.         ProjectItemRepository $projectItemRepository,
  29.         InfrastructureSettingsRepository $infrastructureSettingsRepository,
  30.         InfrastructureItemRepository $infrastructureItemRepository,
  31.         InfrastructureTypeRepository $infrastructureTypeRepository,
  32.         PaymentRepository $paymentRepository,
  33.         RealtyItemsViewMaker $realtyItemsViewMaker,
  34.         AdvantageSettingsRepository $advantageSettingsRepository,
  35.         ConstructionProgressAlbumRepository $constructionProgressAlbumRepository,
  36.         CountByRoomsGenerator $countByRoomsGenerator,
  37.         GenplanSettingsRepository $genplanSettingsRepository,
  38.         PopupRepository $popupRepository,
  39.         AdvantageRepository $advantageRepository,
  40.     ): Response {
  41.         $heroSettings $heroSettingsRepository->getOrCreate();
  42.         $infrastructureSettings $infrastructureSettingsRepository->getOrCreate();
  43.         $infrastructureItems $infrastructureItemRepository->findAll();
  44.         $infrastructureTypes $infrastructureTypeRepository->findAll();
  45.         $heroSettings $heroSettingsRepository->getOrCreate();
  46.         $payment $paymentRepository->findAll();
  47.         $countObjects $countByRoomsGenerator->handle();
  48.         $realtyView $realtyItemsViewMaker->getView($request);
  49.         $heroSettings $heroSettingsRepository->getOrCreate();
  50.         $projectItems $projectItemRepository->getOrderedProjectItems();
  51.         $advantageSettings $advantageSettingsRepository->getOrCreate();
  52.         $advantages $advantageRepository->getSortedAdvantages();
  53.         $constructionAlbums $constructionProgressAlbumRepository->findAll();
  54.         $popup $popupRepository->findOneBy([]);
  55.         return $this->render('pages/index/index.html.twig', [
  56.             'isIndex' => true,
  57.             'heroSettings' => $heroSettings,
  58.             'projectItems' => $projectItems,
  59.             'infrastructureSettings' => $infrastructureSettings,
  60.             'infrastructureItems' => $infrastructureItems,
  61.             'infrastructureTypes' => $infrastructureTypes,
  62.             'payment' => $payment,
  63.             'realtyPager' => $realtyView->getPagination(),
  64.             'realtyFilter' => $realtyView->getRealtyFilter(),
  65.             'advantageSettings' => $advantageSettings,
  66.             'advantages' => $advantages,
  67.             'constructionAlbums' => $constructionAlbums,
  68.             'countObjects' => $countObjects,
  69.             'genplanSetting' => $genplanSettingsRepository->find(1),
  70.             'popup' => $popup
  71.         ]);
  72.     }
  73.     #[Route(path'/test'name'main:test')]
  74.     public function test(Request $request): Response
  75.     {
  76.         $form $this->createForm(RecallType::class);
  77.         $form->handleRequest($request);
  78.         if ($form->isSubmitted() && $form->isValid()) {
  79.             $data $form->getData();
  80.             // ... выполнить некоторое действие, например, сохранить данные в DB
  81.             return $this->redirect($request->getUri());
  82.         }
  83. //        return $this->render('pages/test/index.html.twig', [
  84. //            'form' => $form->createView()
  85. //        ]);
  86.         return $this->render('bundles/TwigBundle/Exception/error404.html.twig', [
  87.             'form' => $form->createView()
  88.         ]);
  89.     }
  90. }