<?php declare(strict_types=1);
namespace App\Main\Controller;
use App\Base\Controller\BaseController;
use App\Content\Repository\Advantage\AdvantageRepository;
use App\Content\Repository\Advantage\AdvantageSettingsRepository;
use App\Content\Repository\ConstructionProgress\ConstructionProgressAlbumRepository;
use App\Content\Repository\Hero\HeroSettingsRepository;
use App\Content\Repository\Infrastructure\InfrastructureItemRepository;
use App\Content\Repository\Infrastructure\InfrastructureSettingsRepository;
use App\Content\Repository\Infrastructure\InfrastructureTypeRepository;
use App\Content\Repository\PaymentRepository;
use App\Content\Repository\Project\ProjectItemRepository;
use App\Leads\Form\RecallType;
use App\Main\Repository\PopupRepository;
use App\Realty\Service\CountByRoomsGenerator;
use App\Realty\Service\RealtyItemsViewMaker;
use App\Realty\Entity\GenplanSettings;
use App\Realty\Repository\GenplanSettingsRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends BaseController
{
#[Route(path: '/', name: 'main:index', options: ['sitemap' => true])]
public function index(
Request $request,
HeroSettingsRepository $heroSettingsRepository,
ProjectItemRepository $projectItemRepository,
InfrastructureSettingsRepository $infrastructureSettingsRepository,
InfrastructureItemRepository $infrastructureItemRepository,
InfrastructureTypeRepository $infrastructureTypeRepository,
PaymentRepository $paymentRepository,
RealtyItemsViewMaker $realtyItemsViewMaker,
AdvantageSettingsRepository $advantageSettingsRepository,
ConstructionProgressAlbumRepository $constructionProgressAlbumRepository,
CountByRoomsGenerator $countByRoomsGenerator,
GenplanSettingsRepository $genplanSettingsRepository,
PopupRepository $popupRepository,
AdvantageRepository $advantageRepository,
): Response {
$heroSettings = $heroSettingsRepository->getOrCreate();
$infrastructureSettings = $infrastructureSettingsRepository->getOrCreate();
$infrastructureItems = $infrastructureItemRepository->findAll();
$infrastructureTypes = $infrastructureTypeRepository->findAll();
$heroSettings = $heroSettingsRepository->getOrCreate();
$payment = $paymentRepository->findAll();
$countObjects = $countByRoomsGenerator->handle();
$realtyView = $realtyItemsViewMaker->getView($request);
$heroSettings = $heroSettingsRepository->getOrCreate();
$projectItems = $projectItemRepository->getOrderedProjectItems();
$advantageSettings = $advantageSettingsRepository->getOrCreate();
$advantages = $advantageRepository->getSortedAdvantages();
$constructionAlbums = $constructionProgressAlbumRepository->findAll();
$popup = $popupRepository->findOneBy([]);
return $this->render('pages/index/index.html.twig', [
'isIndex' => true,
'heroSettings' => $heroSettings,
'projectItems' => $projectItems,
'infrastructureSettings' => $infrastructureSettings,
'infrastructureItems' => $infrastructureItems,
'infrastructureTypes' => $infrastructureTypes,
'payment' => $payment,
'realtyPager' => $realtyView->getPagination(),
'realtyFilter' => $realtyView->getRealtyFilter(),
'advantageSettings' => $advantageSettings,
'advantages' => $advantages,
'constructionAlbums' => $constructionAlbums,
'countObjects' => $countObjects,
'genplanSetting' => $genplanSettingsRepository->find(1),
'popup' => $popup
]);
}
#[Route(path: '/test', name: 'main:test')]
public function test(Request $request): Response
{
$form = $this->createForm(RecallType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
// ... выполнить некоторое действие, например, сохранить данные в DB
return $this->redirect($request->getUri());
}
// return $this->render('pages/test/index.html.twig', [
// 'form' => $form->createView()
// ]);
return $this->render('bundles/TwigBundle/Exception/error404.html.twig', [
'form' => $form->createView()
]);
}
}