vendredi 8 avril 2016

symfony2 Catchable Fatal Error: Object of class could not be converted to string

I generate entities from DB, This DB contains two tables Product and Marque, A product must contain a marque, So we gonna have a foreign key of marque on product table, For more details :

Produit.php :

<?php

namespace TNM\ResponsableEnseigneBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Produit
 *
 * @ORM\Table(name="produit", uniqueConstraints={@ORM\UniqueConstraint(name="REFERENCE", columns={"REFERENCE"})}, indexes={@ORM\Index(name="FK_MARQUE", columns={"ID_MARQUE"})})
 * @ORM\Entity
 */
class Produit
{
    /**
     * @var integer
     *
     * @ORM\Column(name="ID", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="REFERENCE", type="string", length=50, nullable=false)
     */
    private $reference;

    /**
     * @var string
     *
     * @ORM\Column(name="NOM", type="string", length=50, nullable=false)
     */
    private $nom;

    /**
     * @var string
     *
     * @ORM\Column(name="TYPE", type="string", length=50, nullable=false)
     */
    private $type;

    /**
     * @var float
     *
     * @ORM\Column(name="PRIX", type="float", precision=10, scale=0, nullable=false)
     */
    private $prix;

    /**
     * @var float
     *
     * @ORM\Column(name="TAUX_REDUCTION", type="float", precision=10, scale=0, nullable=false)
     */
    private $tauxReduction;

    /**
     * @var integer
     *
     * @ORM\Column(name="NOMBRE_POINT", type="integer", nullable=false)
     */
    private $nombrePoint;

    /**
     * @var string
     *
     * @ORM\Column(name="PHOTO", type="string", length=200, nullable=false)
     */
    private $photo;

    /**
     * @var string
     *
     * @ORM\Column(name="DESCRIPTION", type="string", length=100, nullable=false)
     */
    private $description;

    /**
     * @var integer
     *
     * @ORM\Column(name="QUANTITE", type="integer", nullable=false)
     */
    private $quantite;

    /**
     * @var integer
     *
     * @ORM\Column(name="QUANTITE_VENDU", type="integer", nullable=false)
     */
    private $quantiteVendu;

    /**
     * @var string
     *
     * @ORM\Column(name="Taille", type="string", length=50, nullable=true)
     */
    private $taille;

    /**
     * @var \Marque
     *
     * @ORM\ManyToOne(targetEntity="Marque")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="ID_MARQUE", referencedColumnName="ID")
     * })
     */
    private $idMarque;



    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set reference
     *
     * @param string $reference
     * @return Produit
     */
    public function setReference($reference)
    {
        $this->reference = $reference;

        return $this;
    }

    /**
     * Get reference
     *
     * @return string 
     */
    public function getReference()
    {
        return $this->reference;
    }

    /**
     * Set nom
     *
     * @param string $nom
     * @return Produit
     */
    public function setNom($nom)
    {
        $this->nom = $nom;

        return $this;
    }

    /**
     * Get nom
     *
     * @return string 
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Set type
     *
     * @param string $type
     * @return Produit
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }

    /**
     * Get type
     *
     * @return string 
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * Set prix
     *
     * @param float $prix
     * @return Produit
     */
    public function setPrix($prix)
    {
        $this->prix = $prix;

        return $this;
    }

    /**
     * Get prix
     *
     * @return float 
     */
    public function getPrix()
    {
        return $this->prix;
    }

    /**
     * Set tauxReduction
     *
     * @param float $tauxReduction
     * @return Produit
     */
    public function setTauxReduction($tauxReduction)
    {
        $this->tauxReduction = $tauxReduction;

        return $this;
    }

    /**
     * Get tauxReduction
     *
     * @return float 
     */
    public function getTauxReduction()
    {
        return $this->tauxReduction;
    }

    /**
     * Set nombrePoint
     *
     * @param integer $nombrePoint
     * @return Produit
     */
    public function setNombrePoint($nombrePoint)
    {
        $this->nombrePoint = $nombrePoint;

        return $this;
    }

    /**
     * Get nombrePoint
     *
     * @return integer 
     */
    public function getNombrePoint()
    {
        return $this->nombrePoint;
    }

    /**
     * Set photo
     *
     * @param string $photo
     * @return Produit
     */
    public function setPhoto($photo)
    {
        $this->photo = $photo;

        return $this;
    }

    /**
     * Get photo
     *
     * @return string 
     */
    public function getPhoto()
    {
        return $this->photo;
    }

    /**
     * Set description
     *
     * @param string $description
     * @return Produit
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

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

    /**
     * Set quantite
     *
     * @param integer $quantite
     * @return Produit
     */
    public function setQuantite($quantite)
    {
        $this->quantite = $quantite;

        return $this;
    }

    /**
     * Get quantite
     *
     * @return integer 
     */
    public function getQuantite()
    {
        return $this->quantite;
    }

    /**
     * Set quantiteVendu
     *
     * @param integer $quantiteVendu
     * @return Produit
     */
    public function setQuantiteVendu($quantiteVendu)
    {
        $this->quantiteVendu = $quantiteVendu;

        return $this;
    }

    /**
     * Get quantiteVendu
     *
     * @return integer 
     */
    public function getQuantiteVendu()
    {
        return $this->quantiteVendu;
    }

    /**
     * Set taille
     *
     * @param string $taille
     * @return Produit
     */
    public function setTaille($taille)
    {
        $this->taille = $taille;

        return $this;
    }

    /**
     * Get taille
     *
     * @return string 
     */
    public function getTaille()
    {
        return $this->taille;
    }

    /**
     * Set idMarque
     *
     * @param \TNM\ResponsableEnseigneBundle\Entity\Marque $idMarque
     * @return Produit
     */
    public function setIdMarque(\TNM\ResponsableEnseigneBundle\Entity\Marque $idMarque = null)
    {
        $this->idMarque = $idMarque;

        return $this;
    }

    /**
     * Get idMarque
     *
     * @return \TNM\ResponsableEnseigneBundle\Entity\Marque
     */
    public function getIdMarque()
    {
        return $this->idMarque;
    }
}

Marque.php

<?php

namespace TNM\ResponsableEnseigneBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/** * Marque * * @ORM\Table(name="marque", indexes={@ORM\Index(name="Nom", columns={"Nom"})}) * @ORM\Entity */ class Marque { /** * @var integer * * @ORM\Column(name="ID", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id;

/**
 * @var string
 *
 * @ORM\Column(name="Nom", type="string", length=50, nullable=false)
 */
private $nom;

/**
 * @var float
 *
 * @ORM\Column(name="seuilAchat", type="float", precision=10, scale=0, nullable=false)
 */
private $seuilachat;

/**
 * @var integer
 *
 * @ORM\Column(name="ID_RESPONSABLE", type="integer", nullable=false)
 */
private $idResponsable;



/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set nom
 *
 * @param string $nom
 * @return Marque
 */
public function setNom($nom)
{
    $this->nom = $nom;

    return $this;
}

/**
 * Get nom
 *
 * @return string 
 */
public function getNom()
{
    return $this->nom;
}

/**
 * Set seuilachat
 *
 * @param float $seuilachat
 * @return Marque
 */
public function setSeuilachat($seuilachat)
{
    $this->seuilachat = $seuilachat;

    return $this;
}

/**
 * Get seuilachat
 *
 * @return float 
 */
public function getSeuilachat()
{
    return $this->seuilachat;
}

/**
 * Set idResponsable
 *
 * @param integer $idResponsable
 * @return Marque
 */
public function setIdResponsable($idResponsable)
{
    $this->idResponsable = $idResponsable;

    return $this;
}

/**
 * Get idResponsable
 *
 * @return integer 
 */
public function getIdResponsable()
{
    return $this->idResponsable;
}

}

When I click on submit i get thie message : Catchable Fatal Error: Object of class TNM\ResponsableEnseigneBundle\Controller\MainController could not be converted to string




Aucun commentaire:

Enregistrer un commentaire