Quantcast
Channel: Grafikart | Derniers Sujets du forum
Viewing all articles
Browse latest Browse all 1542

crud

$
0
0

Bonjour,
je suis entraint de vouloir générer le crud de mon application, je suis sur symfony 4.21.6 .
tout d'abord j'ai saisir par moi-même les entités, ensuite j'ai essayé d'implementer le crud de deux entités juste pour apprendre le système de fonctionnement de symfony, ok ensuite j'ai voulu passer à la vitesse supérieure c'est dire générer tous les crud des entités restantes. pour le première entité générée soit l'entité propriétaire, tous a bien fonctionné mais pour les autres entités le crud ne fonctionne pas lorsque je clique sur edit ou show ou create de le seconde entité j'ai cette erreur ":GiBundle\Entity\Proprietaire object not found by the @ParamConverter annotation.," je suis debutant en symfony; j'ai beau chercher je ne trouve rien!

merci pour votre aide

Voila je rencontre un petit problème avec mon code.
//routing/commande

commande_index:
path: /index
defaults: { _controller: "GiBundle:Commande:index" }
methods: GET

commande_show:
path: /{id_commande}/show
defaults: { _controller: "GiBundle:Commande:show" }
methods: GET

commande_new:
path: /new
defaults: { _controller: "GiBundle:Commande:new" }
methods: [GET, POST]

commande_edit:
path: /{id_commande}/edit
defaults: { _controller: "GiBundle:Commande:edit" }
methods: [GET, POST]

commande_delete:
path: /{id_commande}/delete
defaults: { _controller: "GiBundle:Commande:delete" }
methods: DELETE

//entité commande
<?php
namespace GiBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

/**

  • @ORM\Entity
    /
    class Commande
    {
    /
    *

    • @ORM\GeneratedValue(strategy="AUTO")
    • @ORM\Id
    • @ORM\Column(type="integer") */

    private $id_commande;

    /**

    • @ORM\Column(type="integer") */

    private $montant;

    /**

    • @ORM\Column(type="string", length=255) */ private $date_commande;

    /**

    • @ORM\Column(type="string", length=255) */ private $description;

    /**

    • @ORM\ManyToOne(targetEntity=Client::class, inversedBy="un_client")
    • @ORM\JoinColumn(name="client_id", referencedColumnName="id_client" ) */ protected $mes_commandes;

    function getDateCommande(){}
    function setDateCommande(){}
    function getMesCommandes(){}
    function setMesCommandes(){}

    /**

    • @return mixed */ public function getId_Commande() { return $this->id_commande; }

    /**

    • @param mixed $id_commande */ public function setId_Commande($id_commande) { $this->id_commande = $id_commande; }

    /**

    • @return mixed */ public function getMontant() { return $this->montant; }

    /**

    • @param mixed $montant */ public function setMontant($montant) { $this->montant = $montant; }

    /**

    • @return mixed */ public function getDate_Commande() { return $this->date_commande; }

    /**

    • @param mixed $date_commande */ public function setDate_Commande($date_commande) { $this->date_commande = $date_commande; }

    /**

    • @return mixed */ public function getMes_Commandes() { return $this->mes_commandes; }

    /**

    • @param mixed $mes_commandes */ public function setMes_Commandes($mes_commandes) { $this->mes_commandes = $mes_commandes; }

    /**

    • @return mixed */ public function getDescription() { return $this->description; }

    /**

    • @param mixed $description */ public function setDescription($description) { $this->description = $description; }

//controlleur de commande

<?php

namespace GiBundle\Controller;

use GiBundle\Entity\Commande;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

/**

  • Commande controller.
    *
    /
    class CommandeController extends Controller
    {
    /
    *

    • Lists all commande entities.
      *
      */
      public function indexAction()
      {
      $em = $this->getDoctrine()->getManager();

      $commandes = $em->getRepository('GiBundle:Commande')->findAll();

      return $this->render('commande/index.html.twig', array(
      'commandes' => $commandes,
      ));
      }

    /**

    • Creates a new commande entity.
      *
      */
      public function newAction(Request $request)
      {
      $commande = new Commande();
      $form = $this->createForm('GiBundle\Form\CommandeType', $commande);
      $form->handleRequest($request);

      if ($form->isSubmitted() && $form->isValid()) {
      $em = $this->getDoctrine()->getManager();
      $em->persist($commande);
      $em->flush();

      return $this->redirectToRoute('commande_show', array('id_commande' => $commande->getId_commande()));
      

      }

      return $this->render('commande/new.html.twig', array(
      'commande' => $commande,
      'form' => $form->createView(),
      ));
      }

    /**

    • Finds and displays a commande entity. * */

    public function showAction(Commande $commande)
    {
    $deleteForm = $this->createDeleteForm($commande);

    return $this->render('commande/show.html.twig', array(
        'commande' => $commande,
        'delete_form' => $deleteForm->createView(),
    ));
    

    }

    /**

    • Displays a form to edit an existing commande entity.
      *
      */
      public function editAction(Request $request, Commande $commande)
      {
      $deleteForm = $this->createDeleteForm($commande);
      $editForm = $this->createForm('GiBundle\Form\CommandeType', $commande);
      $editForm->handleRequest($request);

      if ($editForm->isSubmitted() && $editForm->isValid()) {
      $this->getDoctrine()->getManager()->flush();

      return $this->redirectToRoute('commande_edit', array('id_commande' => $commande->getIdcommande()));
      

      }

      return $this->render('Commande/edit.html.twig', array(
      'commande' => $commande,
      'edit_form' => $editForm->createView(),
      'delete_form' => $deleteForm->createView(),
      ));
      }

    /**

    • Deletes a commande entity.
      *
      */
      public function deleteAction(Request $request, Commande $commande)
      {
      $form = $this->createDeleteForm($commande);
      $form->handleRequest($request);

      if ($form->isSubmitted() && $form->isValid()) {
      $em = $this->getDoctrine()->getManager();
      $em->remove($commande);
      $em->flush();
      }

      return $this->redirectToRoute('commande_index');
      }

    /**

    • Creates a form to delete a commande entity. *
    • @param Commande $commande The commande entity *
    • @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Commande $commande) { return $this->createFormBuilder() ->setAction($this->generateUrl('commande_delete', array('id_commande' => $commande->getId_commande()))) ->setMethod('DELETE') ->getForm() ; } }

}

Décrivez ici votre code ou ce que vous cherchez à faire

Entourez votre code pour bien le mettre en forme

Ce que je veux

Décrivez ici ce que vous cherchez à obtenir

GiBundle\Entity\Proprietaire object not found by the @ParamConverter annotation.,

Décrivez ici vos erreurs ou ce que vous obtenez à la place de ce que vous attendez :(


Viewing all articles
Browse latest Browse all 1542

Trending Articles