ProBundle/Controller/PrestationController.php line 14

Open in your IDE?
  1. <?php
  2. namespace ProBundle\Controller;
  3. use App\Entity\PrestationEntreprise;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. class PrestationController extends AbstractController
  9. {
  10.     #[Route('/prestation/{slug}'name'pro_prestation_show')]
  11.     public function index(EntityManagerInterface $entityManager$slug)
  12.     {
  13.           //On récupère l'objet prestationEntreprise isActive true
  14.           $prestation $entityManager->getRepository(PrestationEntreprise::class)
  15.           ->findOneBySlug($slug);
  16.           if ($prestation == null) {
  17.             $this->addFlash('danger'"Cette préstation n'existe pas, veuillez en séléctionner une autre.");
  18.             return $this->redirectToRoute('pro_home_index');
  19.           }
  20.         return $this->render('@probundle/probundle/prestation/index.html.twig', [
  21.             'prestation' => $prestation
  22.         ]);
  23.     }
  24. }