object not found by the @ParamConverter annotation.

Par Anthony DUBOIS, il y a 6 ans


Bonjour,

J'ai actuellement un problème que je n'arrive pas à résoudre...
**App\Entity\Comment object not found by the @ParamConverter annotation.

J'ai beau chercher je trouve aucune solution, je vois vraiment pas ou ça peut clocher...

<?php namespace App\Controller; use App\Entity\Comment; use App\Entity\Patient; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Routing\Annotation\Route; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class AdminCommentController extends AbstractController { /** * Permet la suppression d'un compte rendu * * @Route("/admin/comment/{id}/delete", name="admin_comment_delete") */ public function index(EntityManagerInterface $manager, Comment $comment){ $manager->remove($comment); $manager->flush(); $this->addFlash( 'success', "La fiche patient de a bien été supprimé" ); return $this->redirectToRoute('admin_ads_index'); } } {% extends 'admin/base.html.twig' %} {% block title %}Fiche du patient {{ patient.fullName }}{% endblock %} {% block body %} <div class="container"> <h1 class="my-5 text-center">Fiche du patient {{ patient.fullName }}</h1> <div class="row"> <div class="col-6"> <ul> <li><strong>Nom : </strong>{{ patient.lastName }}</li> <li><strong>Prénom : </strong>{{ patient.firstName }}</li> <li><strong>Date de naissance : </strong>{{ patient.birthday }}</li> <li><strong>Adresse : </strong>{{ patient.adresse }}</li> <li><strong>Email : </strong>{{ patient.email }}</li> <li><strong>Téléphone : </strong>{{ patient.tel }}</li> <li><strong>Médecin traitant : </strong>{{ patient.doctor }}</li> </ul> </div> <div class="col-6"> {#<a href="{{ path('admin_comment_create', { 'id': patient.id }) }}" class="btn btn-success float-right">Ajouter un bilan</a>#} </div> </div> <hr class="my-5"> {% if patient.comments is empty %} <p class="text-center">Pas encore de compte rendu pour ce patient</p> {% else %} {% for comment in patient.comments %} <div class="jumbotron"> <h2 class="h3 text-center mb-5">RDV du {{ comment.date }}</h2> <p>{{ comment.observation }}</p> <p>{{ comment.bilan }}</p> <p class="float-right mt-2">Prix de la séance : {{ comment.price }}&euro;</p> <a href="{{ path('admin_comment_delete', { 'id': comment.id }) }}"><small>{{ comment.id }} Supprimer</small></a> </div> {% endfor %} {% endif %} <button id="addCom" class="my-5 btn btn-primary ml-auto">Ajout d'un compte rendu</button> <div id="formCom"> <h1 class="my-5">Ajout d'un compte rendu</h1> {{ form_start(form) }} {{ form_widget(form) }} <button type="submit" class="btn btn-success">Ajouter le compte rendu</button> {{ form_end(form) }} </div> </div> {% endblock %} <?php namespace App\Entity; use App\Repository\CommentRepository; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=CommentRepository::class) */ class Comment { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $date; /** * @ORM\Column(type="float") */ private $price; /** * @ORM\Column(type="text") */ private $observation; /** * @ORM\Column(type="text") */ private $bilan; /** * @ORM\ManyToOne(targetEntity=Patient::class, inversedBy="comments") */ private $patient; public function getId(): ?int { return $this->id; } public function getDate(): ?string { return $this->date; } public function setDate(string $date): self { $this->date = $date; return $this; } public function getPrice(): ?float { return $this->price; } public function setPrice(float $price): self { $this->price = $price; return $this; } public function getObservation(): ?string { return $this->observation; } public function setObservation(string $observation): self { $this->observation = $observation; return $this; } public function getBilan(): ?string { return $this->bilan; } public function setBilan(string $bilan): self { $this->bilan = $bilan; return $this; } public function getPatient(): ?Patient { return $this->patient; } public function setPatient(?Patient $patient): self { $this->patient = $patient; return $this; } }

1 réponse

le-dams, il y a 5 ans

Hello,
Sans certitude mais il me semble qu'il manque dans ta class Comment la mention si dessous

@ORM\Table(name="comment")

<?php namespace App\Entity; use App\Repository\CommentRepository; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Table(name="comment") * @ORM\Entity(repositoryClass=CommentRepository::class) */ class Comment {

B.A.T.