Correction du href et amélioration du controller
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Species;
|
||||||
use App\Repository\SpeciesRepository;
|
use App\Repository\SpeciesRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
@@ -19,9 +20,8 @@ class SpeciesController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/species/{id}', name: 'app_species_detail')]
|
#[Route('/species/{id}', name: 'app_species_detail')]
|
||||||
public function detail(SpeciesRepository $repository,int $id): Response
|
public function detail(Species $specie): Response
|
||||||
{
|
{
|
||||||
$specie = $repository->findOneBy(array('id'=>$id));
|
|
||||||
return $this->render('species/detail.html.twig', [
|
return $this->render('species/detail.html.twig', [
|
||||||
'specie' => $specie,
|
'specie' => $specie,
|
||||||
]);
|
]);
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
<dl>
|
<dl>
|
||||||
{% for specie in species %}
|
{% for specie in species %}
|
||||||
<dt>
|
<dt>
|
||||||
<a href={{ "http://" ~ app.request.host ~ ":8000" ~ "/species/" ~ specie.getId }}>
|
<a href={{ url('app_species') ~ '/' ~ specie.getId }}>
|
||||||
🌿 {{ specie.getVernacularName }}
|
🌿 {{ specie.getVernacularName }}
|
||||||
</a>
|
</a>
|
||||||
</dt>
|
</dt>
|
||||||
|
Reference in New Issue
Block a user