<?php
namespace App\Controller;
use App\Entity\Contenu\Plante;
use App\Repository\Contenu\PlanteRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class PlanteController
*
* @package App\Controller
*/
class PlanteController extends AbstractController
{
/**
* @Route("/plantes/{slug}", name="plante.detail", defaults={"seoEntity" = "Contenu\Plante"}, requirements={"slug":".+"})
* @ParamConverter("plante", class="App:Contenu\Plante", options={"repository_method"="findByTranslatedSlug", "map_method_signature" = true})
* @return Response
*/
public function detail(Plante $plante, PlanteRepository $planteRepository): Response
{
$planteCirculationSanguines = $planteRepository->findBy(['type' => Plante::TYPE_CIRCULATION_SANGUINE, 'visible' => true], ['position' => 'ASC']);
$planteEliminationEaus = $planteRepository->findBy(['type' => Plante::TYPE_ELIMINATION_EAU, 'visible' => true], ['position' => 'ASC']);
$planteTonusEtEnergie = $planteRepository->findBy(['type' => Plante::TYPE_TONUS_ET_ENERGIE, 'visible' => true], ['position' => 'ASC']);
switch ($plante->getType()) {
case Plante::TYPE_CIRCULATION_SANGUINE:
$planteCirculationSanguineSelected = $plante;
$planteEliminationEauSelected = $planteRepository->findFirstByType(Plante::TYPE_ELIMINATION_EAU);
$planteTonusEtEnergieSelected = $planteRepository->findFirstByType(Plante::TYPE_TONUS_ET_ENERGIE);
break;
case Plante::TYPE_ELIMINATION_EAU:
$planteCirculationSanguineSelected = $planteRepository->findFirstByType(Plante::TYPE_CIRCULATION_SANGUINE);
$planteEliminationEauSelected = $plante;
$planteTonusEtEnergieSelected = $planteRepository->findFirstByType(Plante::TYPE_TONUS_ET_ENERGIE);
break;
case Plante::TYPE_TONUS_ET_ENERGIE:
$planteCirculationSanguineSelected = $planteRepository->findFirstByType(Plante::TYPE_CIRCULATION_SANGUINE);
$planteEliminationEauSelected = $planteRepository->findFirstByType(Plante::TYPE_ELIMINATION_EAU);
$planteTonusEtEnergieSelected = $plante;
break;
default:
break;
}
// if (Plante::TYPE_CIRCULATION_SANGUINE === $plante->getType()) {
// $planteCirculationSanguineSelected = $plante;
// $planteEliminationEauSelected = $planteRepository->findFirstByType(Plante::TYPE_ELIMINATION_EAU);
// } else {
// $planteCirculationSanguineSelected = $planteRepository->findFirstByType(Plante::TYPE_CIRCULATION_SANGUINE);
// $planteEliminationEauSelected = $plante;
// }
return $this->render('plante/detail.html.twig', [
'planteCirculationSanguines' => $planteCirculationSanguines,
'planteCirculationSanguineSelected' => $planteCirculationSanguineSelected,
'planteEliminationEaus' => $planteEliminationEaus,
'planteEliminationEauSelected' => $planteEliminationEauSelected,
'planteTonusEtEnergies' => $planteTonusEtEnergie,
'planteTonusEtEnergiesSelected' => $planteTonusEtEnergieSelected,
]);
}
}