src/Controller/HomeController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\Ecommerce\Interfaces\GiftRepositoryInterface;
  4. use App\Repository\Interfaces\HotelRepositoryInterface;
  5. use App\Repository\News\Interfaces\PostRepositoryInterface;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use WAM\Bundle\CoreBundle\Controller\Traits\RendererControllerTrait;
  8. use WAM\Bundle\CoreBundle\Util\Interfaces\RendererAwareInterface;
  9. use WAM\Bundle\NewsBundle\Repository\Interfaces\PostCategoryRepositoryInterface;
  10. use WAM\Bundle\WebContentBundle\Repository\Interfaces\ReviewRepositoryInterface;
  11. /**
  12.  * @author Gerard Rico <grico@wearemarketing.com>
  13.  */
  14. class HomeController implements RendererAwareInterface
  15. {
  16.     use RendererControllerTrait;
  17.     private HotelRepositoryInterface $hotelRepository;
  18.     private ReviewRepositoryInterface $reviewRepository;
  19.     private PostRepositoryInterface $postRepository;
  20.     private PostCategoryRepositoryInterface $postCategoryRepository;
  21.     private GiftRepositoryInterface $giftRepository;
  22.     public function __construct(
  23.         HotelRepositoryInterface $hotelRepository,
  24.         ReviewRepositoryInterface $reviewRepository,
  25.         PostRepositoryInterface $postRepository,
  26.         PostCategoryRepositoryInterface $postCategoryRepository,
  27.         GiftRepositoryInterface $giftRepository
  28.     ) {
  29.         $this->hotelRepository $hotelRepository;
  30.         $this->reviewRepository $reviewRepository;
  31.         $this->postRepository $postRepository;
  32.         $this->postCategoryRepository $postCategoryRepository;
  33.         $this->giftRepository $giftRepository;
  34.     }
  35.     public function __invoke(Request $request)
  36.     {
  37.         $hotels $this->hotelRepository->getAll();
  38.         $reviews $this->reviewRepository->getByLocale($request->getLocale());
  39.         $posts $this->postRepository->getLatestPosts($request->getLocale(), 5);
  40.         $postCategories $this->postCategoryRepository->getAll();
  41.         $popularGifts $this->giftRepository->getPopularGifts();
  42.         return $this->render(
  43.             'default/home.html.twig',
  44.             [
  45.                 'hotels' => $hotels,
  46.                 'reviews' => $reviews,
  47.                 'posts' => $posts,
  48.                 'categories' => $postCategories,
  49.                 'popular_gifts' => $popularGifts,
  50.                 'isHome' => true,
  51.             ]
  52.         );
  53.     }
  54. }