<?php
namespace App\Controller;
use App\Repository\ImagebackgroundRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Repository\ServiceRepository;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
class ServicesController extends AbstractController
{
/**
* @var ServiceRepository
*/
private $repository;
/**
* @var EntityManagerInterface
*/
private $em;
/**
* @var ImagebackgroundRepository
*/
private $i_repository;
public function __construct(ServiceRepository $repository, EntityManagerInterface $em, ImagebackgroundRepository $i_repository)
{
$this->repository = $repository;
$this->em = $em;
$this->i_repository = $i_repository;
}
/**
* @Route("/sevices/", name="services")
* @return Response
*/
public function services(PaginatorInterface $paginator, Request $request): Response
{
$image = $this->i_repository->find(1);
$services = $paginator->paginate(
$this->repository->findServices(),
$request->query->getInt('page', 1),
6
);
return $this->render('pages/services.html.twig', [
'current_menu' => 'services',
'services' => $services,
'img' => $image
]);
}
/**
* @Route("service/single/{id}", name="service.single")
* @return Response
*/
public function servicesingle($id): Response
{
$image = $this->i_repository->find(1);
$service = $this->repository->find($id);
return $this->render('pages/single/service_single.html.twig', [
'service' => $service,
'img' => $image
]);
}
}