<?php
namespace App\Controller;
use App\Repository\Ecommerce\Interfaces\GiftRepositoryInterface;
use App\Repository\Interfaces\HotelRepositoryInterface;
use App\Repository\News\Interfaces\PostRepositoryInterface;
use Symfony\Component\HttpFoundation\Request;
use WAM\Bundle\CoreBundle\Controller\Traits\RendererControllerTrait;
use WAM\Bundle\CoreBundle\Util\Interfaces\RendererAwareInterface;
use WAM\Bundle\NewsBundle\Repository\Interfaces\PostCategoryRepositoryInterface;
use WAM\Bundle\WebContentBundle\Repository\Interfaces\ReviewRepositoryInterface;
/**
* @author Gerard Rico <grico@wearemarketing.com>
*/
class HomeController implements RendererAwareInterface
{
use RendererControllerTrait;
private HotelRepositoryInterface $hotelRepository;
private ReviewRepositoryInterface $reviewRepository;
private PostRepositoryInterface $postRepository;
private PostCategoryRepositoryInterface $postCategoryRepository;
private GiftRepositoryInterface $giftRepository;
public function __construct(
HotelRepositoryInterface $hotelRepository,
ReviewRepositoryInterface $reviewRepository,
PostRepositoryInterface $postRepository,
PostCategoryRepositoryInterface $postCategoryRepository,
GiftRepositoryInterface $giftRepository
) {
$this->hotelRepository = $hotelRepository;
$this->reviewRepository = $reviewRepository;
$this->postRepository = $postRepository;
$this->postCategoryRepository = $postCategoryRepository;
$this->giftRepository = $giftRepository;
}
public function __invoke(Request $request)
{
$hotels = $this->hotelRepository->getAll();
$reviews = $this->reviewRepository->getByLocale($request->getLocale());
$posts = $this->postRepository->getLatestPosts($request->getLocale(), 5);
$postCategories = $this->postCategoryRepository->getAll();
$popularGifts = $this->giftRepository->getPopularGifts();
return $this->render(
'default/home.html.twig',
[
'hotels' => $hotels,
'reviews' => $reviews,
'posts' => $posts,
'categories' => $postCategories,
'popular_gifts' => $popularGifts,
'isHome' => true,
]
);
}
}