src/Controller/PlanteController.php line 67

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Contenu\Plante;
  4. use App\Repository\Contenu\PlanteRepository;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. /**
  10.  * Class PlanteController
  11.  *
  12.  * @package App\Controller
  13.  */
  14. class PlanteController extends AbstractController
  15. {
  16.     /**
  17.      * @Route("/plantes/{slug}", name="plante.detail", defaults={"seoEntity" = "Contenu\Plante"}, requirements={"slug":".+"})
  18.      * @ParamConverter("plante", class="App:Contenu\Plante", options={"repository_method"="findByTranslatedSlug", "map_method_signature" = true})
  19.      * @return Response
  20.      */
  21.     public function detail(Plante $plantePlanteRepository $planteRepository): Response
  22.     {
  23.         $planteCirculationSanguines $planteRepository->findBy(['type' => Plante::TYPE_CIRCULATION_SANGUINE'visible' => true], ['position' => 'ASC']);
  24.         $planteEliminationEaus $planteRepository->findBy(['type' => Plante::TYPE_ELIMINATION_EAU'visible' => true], ['position' => 'ASC']);
  25.         $planteTonusEtEnergie $planteRepository->findBy(['type' => Plante::TYPE_TONUS_ET_ENERGIE'visible' => true], ['position' => 'ASC']);
  26.         switch ($plante->getType()) {
  27.             case Plante::TYPE_CIRCULATION_SANGUINE:
  28.                 $planteCirculationSanguineSelected $plante;
  29.                 $planteEliminationEauSelected $planteRepository->findFirstByType(Plante::TYPE_ELIMINATION_EAU);
  30.                 $planteTonusEtEnergieSelected $planteRepository->findFirstByType(Plante::TYPE_TONUS_ET_ENERGIE);
  31.                 break;
  32.             
  33.             case Plante::TYPE_ELIMINATION_EAU:
  34.                 $planteCirculationSanguineSelected $planteRepository->findFirstByType(Plante::TYPE_CIRCULATION_SANGUINE); 
  35.                 $planteEliminationEauSelected $plante;
  36.                 $planteTonusEtEnergieSelected $planteRepository->findFirstByType(Plante::TYPE_TONUS_ET_ENERGIE);
  37.                 break;
  38.             
  39.             case Plante::TYPE_TONUS_ET_ENERGIE:
  40.                 $planteCirculationSanguineSelected $planteRepository->findFirstByType(Plante::TYPE_CIRCULATION_SANGUINE);
  41.                 $planteEliminationEauSelected $planteRepository->findFirstByType(Plante::TYPE_ELIMINATION_EAU);
  42.                 $planteTonusEtEnergieSelected $plante;
  43.                 break;
  44.             default:
  45.                 break;
  46.         }
  47.         // if (Plante::TYPE_CIRCULATION_SANGUINE === $plante->getType()) {
  48.         //     $planteCirculationSanguineSelected = $plante;
  49.         //     $planteEliminationEauSelected = $planteRepository->findFirstByType(Plante::TYPE_ELIMINATION_EAU);
  50.         // } else {
  51.         //     $planteCirculationSanguineSelected = $planteRepository->findFirstByType(Plante::TYPE_CIRCULATION_SANGUINE);
  52.         //     $planteEliminationEauSelected = $plante;
  53.         // }
  54.         return $this->render('plante/detail.html.twig', [
  55.             'planteCirculationSanguines' => $planteCirculationSanguines,
  56.             'planteCirculationSanguineSelected' => $planteCirculationSanguineSelected,
  57.             'planteEliminationEaus' => $planteEliminationEaus,
  58.             'planteEliminationEauSelected' => $planteEliminationEauSelected,
  59.             'planteTonusEtEnergies' => $planteTonusEtEnergie,
  60.             'planteTonusEtEnergiesSelected' => $planteTonusEtEnergieSelected,
  61.         ]);
  62.     }
  63. }