<?php
namespace App\Controller;
use App\Helper\LastModifyHelper;
use App\Repository\ShopExampleRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
class ShopController extends AbstractController
{
private LastModifyHelper $tracker;
public function __construct(KernelInterface $appKernel)
{
$this->tracker = new LastModifyHelper($appKernel);
}
/**
* @Route("/shop", name="shop.ru")
*/
public function index(ShopExampleRepository $repository): Response
{
$template = 'shop/index.html.twig';
$modified = $this->tracker->get($template);
$response = $this->render($template, [
'examples' => $repository->findAllOrdered(),
'modified' => $modified,
]);
$response->headers->set('Last-Modified', $modified);
return $response;
}
}