I tried to do an dynamic render view in my website with dynamic url. I tried to write an function to do that.
public function html(Name $formation, string $slug, Html $name): Response
{
if($formation->getSlug() !== $slug){
return $this->redirectToRoute('html', [
'id' => $formation->getId(),
'slug' => $formation->getSlug(),
'name' => $name->getName()
], 301);
}
return $this->render('html_css/'.$name.'.html.twig');
}
All stuffs is in a database but when I tried to return the render $name got an issues : (Method '__toString' is not implemented for '\App\Entity\Html') but $name is an string
public function getName(): ?string
{
return $this->name;
}
So why I have this issues ?
Do you thinks they are better solution to do what I want ? I try to search on routing documentation of symfony but don't find what I wan't.
Thanks for your answer !
Aucun commentaire:
Enregistrer un commentaire