src/Controller/ServicesController.php line 63

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\ImagebackgroundRepository;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use App\Repository\ServiceRepository;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Knp\Component\Pager\PaginatorInterface;
  10. use Symfony\Component\HttpFoundation\Request;
  11. class ServicesController extends AbstractController
  12. {
  13.     /**
  14.      * @var ServiceRepository
  15.      */
  16.     private $repository;
  17.     /**
  18.      * @var EntityManagerInterface
  19.      */
  20.     private $em;
  21.     /**
  22.      * @var ImagebackgroundRepository
  23.      */
  24.     private $i_repository;
  25.     public function __construct(ServiceRepository $repositoryEntityManagerInterface $emImagebackgroundRepository $i_repository)
  26.     {
  27.         $this->repository $repository;
  28.         $this->em $em;
  29.         $this->i_repository $i_repository;
  30.     }
  31.     /**
  32.      * @Route("/sevices/", name="services")
  33.      * @return Response
  34.      */
  35.     public function services(PaginatorInterface $paginatorRequest $request): Response
  36.     {
  37.         $image $this->i_repository->find(1);
  38.         $services $paginator->paginate(
  39.             $this->repository->findServices(),
  40.             $request->query->getInt('page'1),
  41.             6
  42.         );
  43.         return $this->render('pages/services.html.twig', [
  44.             'current_menu' => 'services',
  45.             'services' => $services,
  46.             'img' => $image
  47.         ]);
  48.     }
  49.     /**
  50.      * @Route("service/single/{id}", name="service.single")
  51.      * @return Response
  52.      */
  53.     public function servicesingle($id): Response
  54.     {
  55.         $image $this->i_repository->find(1);
  56.         $service $this->repository->find($id);
  57.         return $this->render('pages/single/service_single.html.twig', [
  58.             'service' => $service,
  59.             'img' => $image
  60.         ]);
  61.     }
  62. }