src/Controller/HomeController.php line 24

  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\BranchOfficeRepository;
  4. use App\Repository\MainCardRepository;
  5. use App\Repository\PartnerRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class HomeController extends AbstractController
  10. {
  11.     private $branchOffices;
  12.     private $mapWidget;
  13.     public function __construct(BranchOfficeRepository $branchOfficeRepository)
  14.     {
  15.         $this->branchOffices $branchOfficeRepository->findWidget2gisIsNotNull();
  16.         shuffle($this->branchOffices);
  17.     }
  18.     #[Route('/'name'homepage')]
  19.     public function index(MainCardRepository $mainCardRepositoryPartnerRepository $partnerRepository): Response
  20.     {
  21.         if ($this->branchOffices)
  22.         {
  23.             $this->mapWidget = ($this->branchOffices)[0]->getWidget2gis();
  24.         }
  25.         else
  26.         {
  27.             $this->mapWidget '';
  28.         }
  29.         return $this->render('home/index.html.twig', [
  30.             'main_cards' => $mainCardRepository->findAll(),
  31.             'partners' => $partnerRepository->findAll(),
  32.             'map_widget' => $this->mapWidget,
  33.         ]);
  34.     }
  35. }