<?php
namespace App\Controller;
use App\Entity\Main\Product\Product;
use App\Repository\Main\BlogRepository;
use App\Repository\Main\Product\ProductRepository;
use App\Repository\Main\Slider\ItemRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
/**
* @Route("/", name="home")
*/
public function index(Request $request, ProductRepository $productRepository,
BlogRepository $blogRepository, ItemRepository $sliderItemRepository): Response
{
$request->query->set('locale', $request->getLocale());
$request->query->set('sort_order', 'ASC');
$request->query->set('sort_by', 'order_number');
$request->query->set('status_id', Product::STATUS['ACTIVE']);
$productPaginator = $productRepository->findByRequest($request);
$request->query->set('sort_by', 'id');
$request->query->set('sort_order', 'DESC');
$request->query->set('per_page', 3);
$blogPaginator = $blogRepository->findByRequest($request);
$sRequest = new Request();
$sRequest->query->add([
'order_number' => 'ASC',
'slider_slug' => 'homepage',
]);
$sliderItemPaginator = $sliderItemRepository->findByRequest($sRequest);
return $this->render('home/index.html.twig', [
'productPaginator' => $productPaginator,
'blogPaginator' => $blogPaginator,
'sliderItemPaginator' => $sliderItemPaginator,
]);
}
}