<?php
namespace ProBundle\Controller;
use App\Entity\PrestationEntreprise;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManagerInterface;
class PrestationController extends AbstractController
{
#[Route('/prestation/{slug}', name: 'pro_prestation_show')]
public function index(EntityManagerInterface $entityManager, $slug)
{
//On récupère l'objet prestationEntreprise isActive true
$prestation = $entityManager->getRepository(PrestationEntreprise::class)
->findOneBySlug($slug);
if ($prestation == null) {
$this->addFlash('danger', "Cette préstation n'existe pas, veuillez en séléctionner une autre.");
return $this->redirectToRoute('pro_home_index');
}
return $this->render('@probundle/probundle/prestation/index.html.twig', [
'prestation' => $prestation
]);
}
}