I have a problem with my Doctrine Entity.
In my module, I have a history to list actions performed by users.
During the process, I use a ManyToOne relation of my Entity towards herself.
When I update an item in my database, I use "setGain()" to refer this result to another, but if I want to cancel an action from user I need to set as null the value of setGain(), but Doctrine doesn't accept it and return :
PHP Catchable fatal error: Argument 1 passed to Paris\Entity\Historique::setGain() must be an instance of Paris\Entity\Historique, null given
My Entity is :
<?php
namespace Paris\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Historique
*
* #ORM\Table(name="paris__historique")
* #ORM\Entity
*/
class Historique {
/**
* #var integer
*
* #ORM\Column(name="id_historique", type="integer", precision=0, scale=0, nullable=false, unique=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id_historique;
/**
* #var integer
*
* #ORM\Column(name="id_jol", type="integer", length=11, precision=0, scale=0, nullable=true, unique=false)
*/
private $id_jol;
/**
* #var string
*
* #ORM\Column(name="action", type="string", length=50, precision=0, scale=0, nullable=false, unique=false)
*/
private $action;
/**
* #var string
*
* #ORM\Column(name="detail", type="text", precision=0, scale=0, nullable=true, unique=false)
*/
private $detail;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="\Paris\Entity\Historique")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="id_gain", referencedColumnName="id_historique", nullable=true)
* })
*/
private $id_gain;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="\Paris\Entity\Parieur")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="id_participant", referencedColumnName="id_participant", nullable=true)
* })
*/
private $id_participant;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="\Paris\Entity\Concours")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="id_concours", referencedColumnName="id_concours", nullable=true)
* })
*/
private $id_concours;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="\Paris\Entity\Periode")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="id_periode", referencedColumnName="id_periode", nullable=true)
* })
*/
private $id_periode;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="\Paris\Entity\Paris")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="id_paris", referencedColumnName="id_paris", nullable=true)
* })
*/
private $id_paris;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="\Paris\Entity\Mise")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="id_mise", referencedColumnName="id_mise", nullable=true)
* })
*/
private $id_mise;
/**
* #var integer
*
* #ORM\Column(name="date_historique", type="integer", length=11, precision=0, scale=0, nullable=false, unique=false)
*/
private $date_historique;
public function getIdHistorique() {
return $this->id_historique;
}
public function setIdJol($idJol) {
$this->id_jol = $idJol;
return $this;
}
public function getIdJol() {
return $this->id_jol;
}
public function setAction($action) {
$this->action = $action;
return $this;
}
public function getAction() {
return $this->action;
}
public function getGain() {
return $this->id_gain;
}
public function setGain(\Paris\Entity\Historique $id_gain) {
$this->id_gain = $id_gain;
return $this;
}
public function setDetail($detail) {
$this->detail = $detail;
return $this;
}
public function getDetail() {
return $this->detail;
}
public function setParieur(\Paris\Entity\Parieur $id_participant) {
$this->id_participant = $id_participant;
return $this;
}
public function getParieur() {
return $this->id_participant;
}
public function setConcours(\Paris\Entity\Concours $id_concours) {
$this->id_concours = $id_concours;
return $this;
}
public function getConcours() {
return $this->id_concours;
}
public function setPeriode(\Paris\Entity\Periode $id_periode) {
$this->id_periode = $id_periode;
return $this;
}
public function getPeriode() {
return $this->id_periode;
}
public function setPari(\Paris\Entity\Paris $id_paris) {
$this->id_paris = $id_paris;
return $this;
}
public function getPari() {
return $this->id_paris;
}
public function setmise(\Paris\Entity\Mise $id_mise) {
$this->id_mise = $id_mise;
return $this;
}
public function getMise() {
return $this->id_mise;
}
public function setDate($dateHistorique) {
$this->date_historique = $dateHistorique;
return $this;
}
public function getDate() {
return $this->date_historique;
}
}
In my database, the associated field is correctly set to Null by default and Nullable.
Can you help me ? ^^
Thank you in advance for your answer.
Define setGain as:
public function setGain(?\Paris\Entity\Historique $id_gain) {
$this->id_gain = $id_gain;
return $this;
}
? in front of class typehint allows to pass null as an argument.
Another option is:
public function setGain(\Paris\Entity\Historique $id_gain = null) {
$this->id_gain = $id_gain;
return $this;
}
Related
I have a Evaluation entity which has one Product and Product which can have several Evaluations. I'm trying to fetch one Product and to get the list of Evaluations associated with my entity
Produit.php
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use phpDocumentor\Reflection\Types\This;
/**
* Produit
*
* #ORM\Table(name="produit", indexes={#ORM\Index(name="fk_idcatedel", columns={"idCategorie"})})
* #ORM\Entity
*/
class Produit
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string|null
*
* #ORM\Column(name="libelle", type="string", length=20, nullable=true)
*/
private $libelle;
/**
* #var float|null
*
* #ORM\Column(name="prix", type="float", precision=10, scale=0, nullable=true)
*/
private $prix;
/**
* #var string|null
*
* #ORM\Column(name="description", type="string", length=50, nullable=true)
*/
private $description;
/**
* #var int
*
* #ORM\Column(name="qt", type="integer", nullable=false)
*/
private $qt;
/**
* #var string|null
*
* #ORM\Column(name="img", type="string", length=255, nullable=true)
*/
private $img;
/**
* #var \Categorie
*
* #ORM\ManyToOne(targetEntity="Categorie")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="idCategorie", referencedColumnName="id")
* })
*/
private $idcategorie;
/**
* #ORM\OneToMany(targetEntity="Evaluation", mappedBy="idProduit")
*/
private $rates;
public function __construct()
{
$this->rates = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setLibelle(?string $libelle): self
{
$this->libelle = $libelle;
return $this;
}
public function getPrix(): ?float
{
return $this->prix;
}
public function setPrix(?float $prix): self
{
$this->prix = $prix;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getQt(): ?int
{
return $this->qt;
}
public function setQt(int $qt): self
{
$this->qt = $qt;
return $this;
}
public function getImg(): ?string
{
return $this->img;
}
public function setImg(?string $img): self
{
$this->img = $img;
return $this;
}
public function getIdcategorie(): ?Categorie
{
return $this->idcategorie;
}
public function setIdcategorie(?Categorie $idcategorie): self
{
$this->idcategorie = $idcategorie;
return $this;
}
/**
* #return Collection|Evaluation[]
*/
public function getRates(): Collection
{
return $this->rates;
}
}
Evaluation.php
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Evaluation
*
* #ORM\Table(name="evaluation", indexes={#ORM\Index(name="fk_idprodevaldel", columns={"id_produit"}), #ORM\Index(name="fk_iduser", columns={"id_user"})})
* #ORM\Entity
*/
class Evaluation
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var int
*
* #ORM\Column(name="note", type="integer", nullable=false)
*/
private $note;
/**
* #var \Produit
*
* #ORM\ManyToOne(targetEntity="Produit", inversedBy="rates")
* #ORM\JoinColumn(name="id_produit", referencedColumnName="id")
*/
private $idProduit;
/**
* #var \Compte
*
* #ORM\ManyToOne(targetEntity="Compte")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="id_user", referencedColumnName="email")
* })
*/
private $idUser;
public function getId(): ?int
{
return $this->id;
}
public function getNote(): ?int
{
return $this->note;
}
public function setNote(int $note): self
{
$this->note = $note;
return $this;
}
public function getIdProduit(): ?Produit
{
return $this->idProduit;
}
public function setIdProduit(?Produit $idProduit): self
{
$this->idProduit = $idProduit;
return $this;
}
public function getIdUser(): ?Compte
{
return $this->idUser;
}
public function setIdUser(?Compte $idUser): self
{
$this->idUser = $idUser;
return $this;
}
}
The database
In my controller I succeed to get informations from the products but rates are empty
$produits = $this->getDoctrine()
->getRepository(Produit::class)
->find(1);
dump($produits);
$rates = $produits->getRates();
dump($rates); // #collection: ArrayCollection is empty
The Output :
The collection is not yet initialized due to lazy loading, and rightfully so. If you don't access at least to an element in the collection, it's pointless to load the whole collection because doctrine can safely assume you'll "discard" it. As soon as you access an element (either by looping onto collection or getting a specific element), the collection will be initialized and you have all items.
Another way is to use an EAGER fetch that will load the whole collection in the hydration phase. I would not reccomend it however, unless you're sure that everytime you load a Produit, you need this collection "ready". Even in the latter case, I would handle the collection "manually" as I recommend not to lose control on it (let's pretend you have A LOT of element inside it).
Read more about proxies and association, here
The line $groupement[] = null === $secteurs ? null : $secteurs->getSecteurid();
in the Eleveurtype.php is not working Please i need Some help
The work i wanted to do is to select one Secteur and then i want to get all groupements belong to the Secteur
This is The EleveurType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('secteurid',EntityType::class, [
'label'=>'Nom du secteur :',
'class' => Secteurs::class,
'choice_label' => 'secteurfr',
'attr'=>[
'class'=>'form-control',
]
])
;
$formModifier = function (FormInterface $form, Secteurs $secteurs = null) {
//$secteurs = null === $secteurs ? [] : $secteurs->getSecteurid();
$groupement[] = null === $secteurs ? null : $secteurs->getSecteurid();
$form->add('groupementid', EntityType::class, [
'class' => Groupements::class,
'placeholder' => '',
'choices' => $groupement,
'attr'=>[
'class'=>'form-control',
]
]);
};
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) use ($formModifier) {
// this would be your entity, i.e. SportMeetup
$data = $event->getData();
$formModifier($event->getForm(), $data->getSecteurid());
}
);
$builder->get('secteurid')->addEventListener(
FormEvents::POST_SUBMIT,
function (FormEvent $event) use ($formModifier) {
// It's important here to fetch $event->getForm()->getData(), as
// $event->getData() will get you the client data (that is, the ID)
$secteur = $event->getForm()->getData();
// since we've added the listener to the child, we'll have to pass on
// the parent to the callback functions!
$formModifier($event->getForm()->getParent(), $secteur);
}
);
}
This is The _form.html.twig Eleveur
{{ form_start(form, {'attr': {'id': 'newform', 'nam': nam } }) }}
{{ form_widget(form) }}
<button type="button" class="{{ classBtnAddEdit|default('btn btnAED btn-success waves-effect waves-light m-1') }} " id="btnAddEdit"><i class="fa fa-check-square-o"></i> Enregistrer</button>
{{ form_end(form) }}
<script>
var $secteur = $('#eleveurs_secteurid');
// When sport gets selected ...
$secteur.change(function() {
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = {};
data[$secteur.attr('name')] = $secteur.val();
// Submit data via AJAX to the form's action path.
$.ajax({
url : $form.attr('nam'), //= $form.attr('action'),
type: $form.attr('method'),
data : data,
success: function(html) {
// Replace current position field ...
$('#eleveurs_groupementid').replaceWith(
// ... with the returned one from the AJAX response.
$(html).find('#eleveurs_groupementid')
);
// Position field now displays the appropriate positions.
}
});
});
</script>
** this is the Eleveur Class Eleveur **
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Eleveurs
*
* #ORM\Table(name="eleveurs", indexes={#ORM\Index(name="fk_relationship_47", columns={"groupementid"}), #ORM\Index(name="fk_relationship_53", columns={"douarid"}), #ORM\Index(name="fk_relationship_16", columns={"secteurid"}), #ORM\Index(name="fk_relationship_49", columns={"villeid"})})
* #ORM\Entity
*/
class Eleveurs
{
/**
* #var int
*
* #ORM\Column(name="eleveurid", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $eleveurid;
/**
* #var string|null
*
* #ORM\Column(name="codeeleveur", type="text", length=65535, nullable=true)
*/
private $codeeleveur;
/**
* #var string|null
*
* #ORM\Column(name="numcin", type="text", length=65535, nullable=true)
*/
private $numcin;
/**
* #var \DateTime|null
*
* #ORM\Column(name="datecin", type="date", nullable=true)
*/
private $datecin;
/**
* #var \DateTime|null
*
* #ORM\Column(name="validitecin", type="date", nullable=true)
*/
private $validitecin;
/**
* #var string|null
*
* #ORM\Column(name="nomfr", type="text", length=65535, nullable=true)
*/
private $nomfr;
/**
* #var string|null
*
* #ORM\Column(name="prenomfr", type="text", length=65535, nullable=true)
*/
private $prenomfr;
/**
* #var string|null
*
* #ORM\Column(name="nomar", type="text", length=65535, nullable=true)
*/
private $nomar;
/**
* #var string|null
*
* #ORM\Column(name="prenomar", type="text", length=65535, nullable=true)
*/
private $prenomar;
/**
* #var \DateTime|null
*
* #ORM\Column(name="dateadhesion", type="date", nullable=true)
*/
private $dateadhesion;
/**
* #var string|null
*
* #ORM\Column(name="adressefr", type="text", length=65535, nullable=true)
*/
private $adressefr;
/**
* #var string|null
*
* #ORM\Column(name="adressear", type="text", length=65535, nullable=true)
*/
private $adressear;
/**
* #var int|null
*
* #ORM\Column(name="effectifovin", type="integer", nullable=true)
*/
private $effectifovin;
/**
* #var int|null
*
* #ORM\Column(name="effectifcaprin", type="integer", nullable=true)
*/
private $effectifcaprin;
/**
* #var \Secteurs
*
* #ORM\ManyToOne(targetEntity="Secteurs")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="secteurid", referencedColumnName="secteurid")
* })
*/
private $secteurid;
/**
* #var \Groupements
*
* #ORM\ManyToOne(targetEntity="Groupements")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="groupementid", referencedColumnName="groupementid")
* })
*/
private $groupementid;
/**
* #var \Villes
*
* #ORM\ManyToOne(targetEntity="Villes")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="villeid", referencedColumnName="villeid")
* })
*/
private $villeid;
/**
* #var \Douars
*
* #ORM\ManyToOne(targetEntity="Douars")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="douarid", referencedColumnName="douarid")
* })
*/
private $douarid;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="Conseilgroupement", mappedBy="eleveurid")
*/
private $conseilgroupementid;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="Droitfonctionement", inversedBy="eleveurid")
* #ORM\JoinTable(name="relationship_32",
* joinColumns={
* #ORM\JoinColumn(name="eleveurid", referencedColumnName="eleveurid")
* },
* inverseJoinColumns={
* #ORM\JoinColumn(name="droitfonctionementid", referencedColumnName="droitfonctionementid")
* }
* )
*/
private $droitfonctionementid;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="Conseilanoc", mappedBy="eleveurid")
*/
private $conseilanocid;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="Superviseurs", mappedBy="eleveurid")
*/
private $histosuperviseurid;
/**
* Constructor
*/
public function __construct()
{
$this->conseilgroupementid = new \Doctrine\Common\Collections\ArrayCollection();
$this->droitfonctionementid = new \Doctrine\Common\Collections\ArrayCollection();
$this->conseilanocid = new \Doctrine\Common\Collections\ArrayCollection();
$this->histosuperviseurid = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getEleveurid(): ?int
{
return $this->eleveurid;
}
public function getCodeeleveur(): ?string
{
return $this->codeeleveur;
}
public function setCodeeleveur(?string $codeeleveur): self
{
$this->codeeleveur = $codeeleveur;
return $this;
}
public function getNumcin(): ?string
{
return $this->numcin;
}
public function setNumcin(?string $numcin): self
{
$this->numcin = $numcin;
return $this;
}
public function getDatecin(): ?\DateTimeInterface
{
return $this->datecin;
}
public function setDatecin(?\DateTimeInterface $datecin): self
{
$this->datecin = $datecin;
return $this;
}
public function getValiditecin(): ?\DateTimeInterface
{
return $this->validitecin;
}
public function setValiditecin(?\DateTimeInterface $validitecin): self
{
$this->validitecin = $validitecin;
return $this;
}
public function getNomfr(): ?string
{
return $this->nomfr;
}
public function setNomfr(?string $nomfr): self
{
$this->nomfr = $nomfr;
return $this;
}
public function getPrenomfr(): ?string
{
return $this->prenomfr;
}
public function setPrenomfr(?string $prenomfr): self
{
$this->prenomfr = $prenomfr;
return $this;
}
public function getNomar(): ?string
{
return $this->nomar;
}
public function setNomar(?string $nomar): self
{
$this->nomar = $nomar;
return $this;
}
public function getPrenomar(): ?string
{
return $this->prenomar;
}
public function setPrenomar(?string $prenomar): self
{
$this->prenomar = $prenomar;
return $this;
}
public function getDateadhesion(): ?\DateTimeInterface
{
return $this->dateadhesion;
}
public function setDateadhesion(?\DateTimeInterface $dateadhesion): self
{
$this->dateadhesion = $dateadhesion;
return $this;
}
public function getAdressefr(): ?string
{
return $this->adressefr;
}
public function setAdressefr(?string $adressefr): self
{
$this->adressefr = $adressefr;
return $this;
}
public function getAdressear(): ?string
{
return $this->adressear;
}
public function setAdressear(?string $adressear): self
{
$this->adressear = $adressear;
return $this;
}
public function getEffectifovin(): ?int
{
return $this->effectifovin;
}
public function setEffectifovin(?int $effectifovin): self
{
$this->effectifovin = $effectifovin;
return $this;
}
public function getEffectifcaprin(): ?int
{
return $this->effectifcaprin;
}
public function setEffectifcaprin(?int $effectifcaprin): self
{
$this->effectifcaprin = $effectifcaprin;
return $this;
}
public function getSecteurid(): ?Secteurs
{
return $this->secteurid;
}
public function setSecteurid(?Secteurs $secteurid): self
{
$this->secteurid = $secteurid;
return $this;
}
public function getGroupementid(): ?Groupements
{
return $this->groupementid;
}
public function setGroupementid(?Groupements $groupementid): self
{
$this->groupementid = $groupementid;
return $this;
}
public function getVilleid(): ?Villes
{
return $this->villeid;
}
public function setVilleid(?Villes $villeid): self
{
$this->villeid = $villeid;
return $this;
}
public function getDouarid(): ?Douars
{
return $this->douarid;
}
public function setDouarid(?Douars $douarid): self
{
$this->douarid = $douarid;
return $this;
}
/**
* #return Collection|Conseilgroupement[]
*/
public function getConseilgroupementid(): Collection
{
return $this->conseilgroupementid;
}
public function addConseilgroupementid(Conseilgroupement $conseilgroupementid): self
{
if (!$this->conseilgroupementid->contains($conseilgroupementid)) {
$this->conseilgroupementid[] = $conseilgroupementid;
$conseilgroupementid->addEleveurid($this);
}
return $this;
}
public function removeConseilgroupementid(Conseilgroupement $conseilgroupementid): self
{
if ($this->conseilgroupementid->contains($conseilgroupementid)) {
$this->conseilgroupementid->removeElement($conseilgroupementid);
$conseilgroupementid->removeEleveurid($this);
<
** This is the Secteur class **
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Secteurs
*
* #ORM\Table(name="secteurs")
* #ORM\Entity
*/
class Secteurs
{
/**
* #var int
*
* #ORM\Column(name="secteurid", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $secteurid;
/**
* #var string|null
*
* #ORM\Column(name="secteurfr", type="text", length=65535, nullable=true)
*/
private $secteurfr;
/**
* #var string|null
*
* #ORM\Column(name="secteurar", type="text", length=65535, nullable=true)
*/
private $secteurar;
/**
* #var string|null
*
* #ORM\Column(name="codesecteur", type="text", length=65535, nullable=true)
*/
private $codesecteur;
public function getSecteurid(): ?int
{
return $this->secteurid;
}
public function getSecteurfr(): ?string
{
return $this->secteurfr;
}
public function setSecteurfr(?string $secteurfr): self
{
$this->secteurfr = ucfirst($secteurfr);
return $this;
}
public function getSecteurar(): ?string
{
return $this->secteurar;
}
public function setSecteurar(?string $secteurar): self
{
$this->secteurar = $secteurar;
return $this;
}
public function getCodesecteur(): ?string
{
return $this->codesecteur;
}
public function setCodesecteur(?string $codesecteur): self
{
$this->codesecteur = strtoupper($codesecteur);
return $this;
}
}
** this is the groupement class **
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Groupements
*
* #ORM\Table(name="groupements", indexes={#ORM\Index(name="fk_relationship_54", columns={"secteurid"})})
* #ORM\Entity
*/
class Groupements
{
/**
* #var int
*
* #ORM\Column(name="groupementid", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $groupementid;
/**
* #var string|null
*
* #ORM\Column(name="groupementmereid", type="decimal", precision=8, scale=0, nullable=true)
*/
private $groupementmereid;
/**
* #var string|null
*
* #ORM\Column(name="codegroupement", type="text", length=65535, nullable=true)
*/
private $codegroupement;
/**
* #var string|null
*
* #ORM\Column(name="nomgroupementfr", type="text", length=65535, nullable=true)
*/
private $nomgroupementfr;
/**
* #var string|null
*
* #ORM\Column(name="nomgroupementar", type="text", length=65535, nullable=true)
*/
private $nomgroupementar;
/**
* #var string|null
*
* #ORM\Column(name="adressepostale", type="text", length=65535, nullable=true)
*/
private $adressepostale;
/**
* #var \DateTime|null
*
* #ORM\Column(name="datecreation", type="date", nullable=true)
*/
private $datecreation;
/**
* #var string|null
*
* #ORM\Column(name="pvcreation", type="text", length=65535, nullable=true)
*/
private $pvcreation;
/**
* #var float|null
*
* #ORM\Column(name="droitfonctionement", type="float", precision=10, scale=0, nullable=true)
*/
private $droitfonctionement;
/**
* #var float|null
*
* #ORM\Column(name="autrecotisations", type="float", precision=10, scale=0, nullable=true)
*/
private $autrecotisations;
/**
* #var string|null
*
* #ORM\Column(name="effectifovinencadre", type="decimal", precision=8, scale=0, nullable=true)
*/
private $effectifovinencadre;
/**
* #var string|null
*
* #ORM\Column(name="effectifcaprinencadre", type="decimal", precision=8, scale=0, nullable=true)
*/
private $effectifcaprinencadre;
/**
* #var string|null
*
* #ORM\Column(name="lieupvcreation", type="text", length=65535, nullable=true)
*/
private $lieupvcreation;
/**
* #var \DateTime|null
*
* #ORM\Column(name="datepvcreation", type="date", nullable=true)
*/
private $datepvcreation;
/**
* #var \Secteurs
*
* #ORM\ManyToOne(targetEntity="Secteurs")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="secteurid", referencedColumnName="secteurid")
* })
*/
private $secteurid;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="Droitfonctionement", inversedBy="groupementid")
* #ORM\JoinTable(name="relationship_31",
* joinColumns={
* #ORM\JoinColumn(name="groupementid", referencedColumnName="groupementid")
* },
* inverseJoinColumns={
* #ORM\JoinColumn(name="droitfonctionementid", referencedColumnName="droitfonctionementid")
* }
* )
*/
private $droitfonctionementid;
/**
* Constructor
*/
public function __construct()
{
$this->droitfonctionementid = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getGroupementid(): ?int
{
return $this->groupementid;
}
public function getGroupementmereid(): ?string
{
return $this->groupementmereid;
}
public function setGroupementmereid(?string $groupementmereid): self
{
$this->groupementmereid = $groupementmereid;
return $this;
}
public function getCodegroupement(): ?string
{
return $this->codegroupement;
}
public function setCodegroupement(?string $codegroupement): self
{
$this->codegroupement = $codegroupement;
return $this;
}
public function getNomgroupementfr(): ?string
{
return $this->nomgroupementfr;
}
public function setNomgroupementfr(?string $nomgroupementfr): self
{
$this->nomgroupementfr = $nomgroupementfr;
return $this;
}
public function getNomgroupementar(): ?string
{
return $this->nomgroupementar;
}
public function setNomgroupementar(?string $nomgroupementar): self
{
$this->nomgroupementar = $nomgroupementar;
return $this;
}
public function getAdressepostale(): ?string
{
return $this->adressepostale;
}
public function setAdressepostale(?string $adressepostale): self
{
$this->adressepostale = $adressepostale;
return $this;
}
public function getDatecreation(): ?\DateTimeInterface
{
return $this->datecreation;
}
public function setDatecreation(?\DateTimeInterface $datecreation): self
{
$this->datecreation = $datecreation;
return $this;
}
public function getPvcreation(): ?string
{
return $this->pvcreation;
}
public function setPvcreation(?string $pvcreation): self
{
$this->pvcreation = $pvcreation;
return $this;
}
public function getDroitfonctionement(): ?float
{
return $this->droitfonctionement;
}
public function setDroitfonctionement(?float $droitfonctionement): self
{
$this->droitfonctionement = $droitfonctionement;
return $this;
}
public function getAutrecotisations(): ?float
{
return $this->autrecotisations;
}
public function setAutrecotisations(?float $autrecotisations): self
{
$this->autrecotisations = $autrecotisations;
return $this;
}
public function getEffectifovinencadre(): ?string
{
return $this->effectifovinencadre;
}
public function setEffectifovinencadre(?string $effectifovinencadre): self
{
$this->effectifovinencadre = $effectifovinencadre;
return $this;
}
public function getEffectifcaprinencadre(): ?string
{
return $this->effectifcaprinencadre;
}
public function setEffectifcaprinencadre(?string $effectifcaprinencadre): self
{
$this->effectifcaprinencadre = $effectifcaprinencadre;
return $this;
}
public function getLieupvcreation(): ?string
{
return $this->lieupvcreation;
}
public function setLieupvcreation(?string $lieupvcreation): self
{
$this->lieupvcreation = $lieupvcreation;
return $this;
}
public function getDatepvcreation(): ?\DateTimeInterface
{
return $this->datepvcreation;
}
public function setDatepvcreation(?\DateTimeInterface $datepvcreation): self
{
$this->datepvcreation = $datepvcreation;
return $this;
}
public function getSecteurid(): ?Secteurs
{
return $this->secteurid;
}
public function setSecteurid(?Secteurs $secteurid): self
{
$this->secteurid = $secteurid;
return $this;
}
/**
* #return Collection|Droitfonctionement[]
*/
public function getDroitfonctionementid(): Collection
{
return $this->droitfonctionementid;
}
public function addDroitfonctionementid(Droitfonctionement $droitfonctionementid): self
{
if (!$this->droitfonctionementid->contains($droitfonctionementid)) {
$this->droitfonctionementid[] = $droitfonctionementid;
}
return $this;
}
public function removeDroitfonctionementid(Droitfonctionement $droitfonctionementid): self
{
if ($this->droitfonctionementid->contains($droitfonctionementid)) {
$this->droitfonctionementid->removeElement($droitfonctionementid);
}
return $this;
}
}
I have a problem with my code. It's about a restaurant. I have two objects with a Many-To-Many relation: Products and Days. When I try to create a Day, I receive this error: "Failed to create object: App\Entity\Day\Day". Where am I wrong?
I put the code for entities here. If you need more just tell me. I don't think that it is from admin part.
Here is the Product entity:
<?php
namespace App\Entity\Product;
use App\Entity\Category\Category;
use App\Entity\Day\Day;
use App\Entity\ProductEntry\ProductEntry;
use App\Entity\Restaurant\Restaurant;
use App\Entity\Schedule\Schedule;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/**
* Class Product
* #ORM\Entity(repositoryClass="App\Repository\Product\ProductRepository")
* #ORM\Table(name="products")
* #package App\Entity\Product
*/
class Product
{
/**
* #var int
*
* #ORM\Id
* #ORM\Column(name="id", type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* #var \DateTime
*
* #ORM\Column(name="added_date", type="datetime", nullable=false)
*/
private $addedDate;
/**
* #var boolean
*
* #ORM\Column(name="availability", type="boolean", nullable=true)
*/
private $availability;
/**
* #var Category
*
* #ORM\ManyToOne(targetEntity="App\Entity\Category\Category", inversedBy="products", cascade={"persist"})
* #ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)
*/
private $category;
/**
* #var float
*
* #ORM\Column(name="price", type="float", length=255, nullable=true)
*/
private $price;
/**
* #var ProductEntry
*
* #ORM\OneToMany(targetEntity="App\Entity\ProductEntry\ProductEntry", mappedBy="originalProduct", cascade={"persist"})
* #Serializer\Exclude()
*/
private $productsEntries;
/**
* #ORM\ManyToOne(targetEntity="App\Entity\Schedule\Schedule", inversedBy="products", cascade={"persist"})
* #ORM\JoinColumn(name="schedule_id", referencedColumnName="id", onDelete="CASCADE")
*
* #var Schedule
*/
private $schedule;
/**
* #ORM\ManyToOne(targetEntity="App\Entity\Restaurant\Restaurant", inversedBy="products", cascade={"persist"})
* #ORM\JoinColumn(name="restaurant_id", referencedColumnName="id", onDelete="CASCADE")
*
* #var Restaurant
*/
private $restaurant;
/**
* #var Day
*
* #ORM\ManyToMany(targetEntity="App\Entity\Day\Day", mappedBy="products", cascade={"persist"})
*/
private $days;
public function __toString()
{
return $this->name ?: "";
}
public function __construct()
{
$this->addedDate = new \DateTime();
$this->days = new ArrayCollection();
}
/**
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* #param int $id
*/
public function setId(int $id)
{
$this->id = $id;
}
/**
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* #param string $name
*/
public function setName(string $name)
{
$this->name = $name;
}
/**
* #return string
*/
public function getDescription()
{
return $this->description;
}
/**
* #param string $description
*/
public function setDescription(string $description)
{
$this->description = $description;
}
/**
* #return mixed
*/
public function getAddedDate()
{
return $this->addedDate;
}
/**
* #param mixed $addedDate
*/
public function setAddedDate($addedDate)
{
$this->addedDate = $addedDate;
}
/**
* #return bool
*/
public function isAvailability()
{
return $this->availability;
}
/**
* #param bool $availability
*/
public function setAvailability($availability)
{
$this->availability = $availability;
}
/**
* #return float
*/
public function getPrice()
{
return $this->price;
}
/**
* #param float $price
*/
public function setPrice($price)
{
$this->price = $price;
}
/**
* #return Category
*/
public function getCategory()
{
return $this->category;
}
/**
* #param Category $category
*/
public function setCategory($category): void
{
$this->category = $category;
}
/**
* #return ProductEntry
*/
public function getProductsEntries()
{
return $this->productsEntries;
}
/**
* #param ProductEntry $productsEntries
*/
public function setProductsEntries(ProductEntry $productsEntries): void
{
$this->productsEntries = $productsEntries;
}
/**
* #return Schedule
*/
public function getSchedule()
{
return $this->schedule;
}
/**
* #param Schedule $schedule
*/
public function setSchedule(Schedule $schedule): void
{
$this->schedule = $schedule;
}
/**
* #return Restaurant
*/
public function getRestaurant()
{
return $this->restaurant;
}
/**
* #param Restaurant $restaurant
*/
public function setRestaurant(Restaurant $restaurant): void
{
$this->restaurant = $restaurant;
}
/**
* #return Day
*/
public function getDays()
{
return $this->days;
}
/**
* #param Day $days
*/
public function setDays(Day $days): void
{
$this->days = $days;
}
}
Here is Day entity:
<?php
namespace App\Entity\Day;
use App\Entity\Product\Product;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Class Day
* #package App\Entity\Day
* #ORM\Entity(repositoryClass="App\Repository\Day\DayRepository")
* #ORM\Table(name="days")
*/
class Day
{
/**
* #var integer
*
* #ORM\Id
* #ORM\Column(name="id", type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", nullable=false)
*/
private $name;
/**
* #var \DateTime
*
* #ORM\Column(name="current_date", type="datetime", nullable=false)
*/
private $currentDate;
/**
* #var \DateTime
*
* #ORM\Column(name="max_date", type="datetime", nullable=true)
*/
private $maxDate;
/**
* #var Product
*
* #ORM\ManyToMany(targetEntity="App\Entity\Product\Product", inversedBy="days", cascade={"persist"})
* #ORM\JoinTable(name="product_day",
* joinColumns={#ORM\JoinColumn(name="day_id", referencedColumnName="id")},
* inverseJoinColumns={#ORM\JoinColumn(name="product_id", referencedColumnName="id")})
*/
private $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
/**
* #return int
*/
public function getId(): int
{
return $this->id;
}
/**
* #param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* #param string $name
*/
public function setName(string $name): void
{
$this->name = $name;
}
/**
* #return \DateTime
*/
public function getCurrentDate()
{
return $this->currentDate;
}
/**
* #param \DateTime $currentDate
*/
public function setCurrentDate(\DateTime $currentDate): void
{
$this->currentDate = $currentDate;
}
/**
* #return \DateTime
*/
public function getMaxDate()
{
return $this->maxDate;
}
/**
* #param \DateTime $maxDate
*/
public function setMaxDate(\DateTime $maxDate): void
{
$this->maxDate = $maxDate;
}
/**
* #return Product
*/
public function getProducts()
{
return $this->products;
}
/**
* #param Product $products
*/
public function setProducts(Product $products): void
{
$this->products = $products;
}
}
It seems that you created a column for your Day Entity that is called current_date
/**
* #var \DateTime
*
* #ORM\Column(name="current_date", type="datetime", nullable=false)
*/
private $currentDate;
If you are using MySQL, current_date is a reserved word. Please check https://dev.mysql.com/doc/refman/5.5/en/keywords.html for further reference.
Like Vincent said in comment, your namespaces are fishy...
Unless you really placed them in a sub-folder, it should be namespace App\Entity
In Product entity you can shorten you JoinColumn for some parameters.
Unless you really need something specific, you don't need to write that much. Symfony have 'default' values.
Also, you don't add #var on a mapping. Symfony will take is as a parameter only instead of mapping.
/**
* #var Category
*
* #ORM\ManyToOne(targetEntity="App\Entity\Category\Category", inversedBy="products", cascade={"persist"})
* #ORM\JoinColumn(onDelete="CASCADE", nullable=true)
*/
private $category;
/**
* #ORM\ManyToOne(targetEntity="App\Entity\Schedule\Schedule", inversedBy="products", cascade={"persist"})
* #ORM\JoinColumn(onDelete="CASCADE")
*/
private $schedule;
/**
* #ORM\ManyToOne(targetEntity="App\Entity\Restaurant\Restaurant", inversedBy="products", cascade={"persist"})
* #ORM\JoinColumn(onDelete="CASCADE")
*/
private $restaurant;
The same apply to your Day entity.
/**
* #var Product
*
* #ORM\ManyToMany(targetEntity="App\Entity\Product\Product", inversedBy="days", cascade={"persist"})
* #ORM\JoinTable(name="product_day")
*/
private $products;
Doing so will prevent you to make some smalls mapping errors.
Try to correct those points first, then let us know if you still have your problem.
when i try to display all users for admin interface i get this error
Notice: unserialize(): Error at offset 0 of 6 bytes
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace AdminBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/**
* Description of AdminController
*
* #author saif
*/
class AdminController extends Controller {
public function valide_compteAction()
{
$em=$this->getDoctrine()->getManager();
$utilisateur=$em->getRepository('WelcomeBundle:Utilisateur')->findall();
return $this->render('AdminBundle:admin:valide_compte.html.twig',array('i'=>$utilisateur));
}
}
and this is my userclass
namespace WelcomeBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use \Symfony\Component\Security\Core\User\AdvancedUserInterface;
use JMS\SerializerBundle\Annotation\Type;
/**
* Utilisateur
*
* #ORM\Table(name="utilisateur")
* #ORM\Entity
*/
class Utilisateur extends BaseUser implements AdvancedUserInterface, \Serializable
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* #var string
*
* #ORM\Column(name="nom", type="string", length=40, nullable=false)
*/
protected $nom;
/**
* #var string
*
* #ORM\Column(name="prenom", type="string", length=40, nullable=false)
*/
protected $prenom;
/**
* #var integer
*
* #ORM\Column(name="numtelphone", type="integer", nullable=true)
*/
protected $numtelphone;
/**
* #var string
*
* #ORM\Column(name="addresse", type="string", length=40, nullable=true)
*/
protected $addresse;
/**
* #var integer
*
* #ORM\Column(name="jeton", type="integer", nullable=true)
*/
protected $jeton;
/**
* #var string
*
* #ORM\Column(name="photo", type="blob", nullable=true)
*/
protected $photo;
/**
* #var string
*
* #ORM\Column(name="mailreclamation", type="string", length=50, nullable=true)
*/
protected $mailreclamation;
public function __construct()
{
parent::__construct();
// your own logic
}
public function getId() {
return $this->id;
}
public function getNom() {
return $this->nom;
}
public function getPrenom() {
return $this->prenom;
}
public function getNumtelphone() {
return $this->numtelphone;
}
public function getAddresse() {
return $this->addresse;
}
public function getJeton() {
return $this->jeton;
}
public function getPhoto() {
return $this->photo;
}
public function getMailreclamation() {
return $this->mailreclamation;
}
public function setId($id) {
$this->id = $id;
}
public function setNom($nom) {
$this->nom = $nom;
}
public function setPrenom($prenom) {
$this->prenom = $prenom;
}
public function setNumtelphone($numtelphone) {
$this->numtelphone = $numtelphone;
}
public function setAddresse($addresse) {
$this->addresse = $addresse;
}
public function setJeton($jeton) {
$this->jeton = $jeton;
}
public function setPhoto($photo) {
$this->photo = $photo;
}
public function setMailreclamation($mailreclamation) {
$this->mailreclamation = $mailreclamation;
}
public function json_encode()
{
return json_encode(array(
$this->password,
$this->salt,
$this->usernameCanonical,
$this->username,
$this->expired,
$this->locked,
$this->credentialsExpired,
$this->enabled,
$this->id,
));
}
}
how can i solve this, i have wasted a lot of time in this
Check the serialized data in the database. Are they consistent? It is possible that the database driver assumes another data type. In this case check the blob type for the photo column. I had had a similar problem with json/array type.
I have the following inventory entity object for Doctrine that I created for use in Symfony 3.0.
Simply put how do I get access to the information that I put in the entity via annotations?
For example, companyID, has a ManyToOne annotation that references inversedBy="location". This particular information is very useful to me so I can tell if its a child relationship by foreign key or parent relationship.
If I can get the information about the entity that I described via annotations somehow in an array with Doctrine that would be great. Is this possible to do? Essentially I'm looking for introspection functions on the entity.
<?php
namespace AppBundle\Entity;
use Gedmo\Translatable\Translatable;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Inventory
*
* #ORM\Table(name="distribution_inventory")
* #ORM\Entity(repositoryClass="AppBundle\Repository\InventoryRepository")
*/
class Inventory implements Translatable {
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
* #Gedmo\Translatable
* #ORM\Column(name="name", type="string", length=255, unique=true)
*/
private $name;
/**
* #var string
* #Gedmo\Slug(fields={"name","id"},suffix=".html")
* #ORM\Column(name="inventoryslug", type="string", length=255, nullable=false, nullable=true)
*/
private $inventoryslug;
/**
* #var string
*
* #ORM\Column(name="barcode", type="string", length=255, nullable=true)
*/
private $barcode;
/**
* #var string
* #Gedmo\Translatable
* #ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* #var string
* #ORM\Column(name="imagename", type="string", nullable=true)
*/
private $imagename;
/**
* #Gedmo\Locale
* Used locale to override Translation listener`s locale
* this is not a mapped field of entity metadata, just a simple property
*/
private $locale;
/**
* #var \AppBundle\Entity\InventoryCategory
*
* #ORM\ManyToOne(targetEntity="\AppBundle\Entity\InventoryCategory")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="categoryid", referencedColumnName="id")
* })
*/
private $category;
/**
* #var \AppBundle\Entity\Company
* #Assert\Type(type="\AppBundle\Entity\Company")
* #Assert\Valid()
* #ORM\ManyToOne(targetEntity="\AppBundle\Entity\Company", inversedBy="Location")
* #ORM\JoinColumn(name="companyid", referencedColumnName="id", onDelete="CASCADE")
*/
protected $companyId;
/**
* #var \DateTime $created
*
* #Gedmo\Timestampable(on="create")
* #ORM\Column(type="datetime")
*/
private $created;
/**
* #var \DateTime $updated
*
* #Gedmo\Timestampable(on="update")
* #ORM\Column(type="datetime")
*/
private $updated;
/**
* #var string
* #ORM\Column(name="defaultsellprice",precision=14, scale=2, nullable=true)
*/
private $defaultsellprice;
/**
* #var boolean
*
* #ORM\Column(name="onwaycount", type="integer", nullable=false)
*/
private $onwaycount;
/**
* #var boolean
*
* #ORM\Column(name="instorecount", type="integer", nullable=false)
*/
private $instorecount;
/**
* #var boolean
*
* #ORM\Column(name="wayoutcount", type="integer", nullable=false)
*/
private $wayoutcount;
/**
* #var boolean
*
* #ORM\Column(name="instore", type="string", length=10, nullable=false)
*/
private $instore;
/**
* #var string
*
* #ORM\Column(name="isarchived", type="string", length=5, nullable=false,options={"default":false})
*/
private $isarchived;
/**
* #var string
*
* #ORM\Column(name="archivestatus", type="string", length=5, nullable=false,options={"default":true})
*/
private $archivestatus;
function __construct() {
$this->onwaycount=0;
$this->instore=FALSE;
$this->instorecount=0;
$this->wayoutcount=0;
}
/**
* Get id
*
* #return int
*/
public function getId() {
return $this->id;
}
/**
* Set name
*
* #param string $name
*
* #return Inventory
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName() {
return $this->name;
}
/**
* Set barcode
*
* #param string $barcode
*
* #return Inventory
*/
public function setBarcode($barcode) {
$this->barcode = $barcode;
return $this;
}
/**
* Get barcode
*
* #return string
*/
public function getBarcode() {
return $this->barcode;
}
/**
* Set description
*
* #param string $description
*
* #return Inventory
*/
public function setDescription($description) {
$this->description = $description;
return $this;
}
/**
* Get description
*
* #return string
*/
public function getDescription() {
return $this->description;
}
public function getImagename() {
return $this->imagename;
}
public function getCategory() {
return $this->category;
}
public function getCompanyId() {
return $this->companyId;
}
public function getCreated() {
return $this->created;
}
public function getUpdated() {
return $this->updated;
}
public function getOnwaycount() {
return $this->onwaycount;
}
public function getInstorecount() {
return $this->instorecount;
}
public function getWayoutcount() {
return $this->wayoutcount;
}
public function getInstore() {
return $this->instore;
}
public function setImagename($imagename) {
$this->imagename = $imagename;
return $this;
}
public function setCategory(\AppBundle\Entity\InventoryCategory $category) {
$this->category = $category;
return $this;
}
public function setCompanyId(\AppBundle\Entity\Company $companyId) {
$this->companyId = $companyId;
return $this;
}
public function setCreated(\DateTime $created) {
$this->created = $created;
return $this;
}
public function setUpdated(\DateTime $updated) {
$this->updated = $updated;
return $this;
}
public function setOnwaycount($onwaycount) {
$this->onwaycount = $onwaycount;
return $this;
}
public function setInstorecount($instorecount) {
$this->instorecount = $instorecount;
return $this;
}
public function setWayoutcount($wayoutcount) {
$this->wayoutcount = $wayoutcount;
return $this;
}
public function setInstore($instore) {
$this->instore = $instore;
return $this;
}
public function getDefaultsellprice() {
return $this->defaultsellprice;
}
public function setDefaultsellprice($defaultsellprice) {
$this->defaultsellprice = $defaultsellprice;
return $this;
}
public function getInventoryslug() {
return $this->inventoryslug;
}
public function setInventoryslug($inventoryslug) {
$this->inventoryslug = $inventoryslug;
return $this;
}
public function setTranslatableLocale($locale) {
$this->locale = $locale;
}
public function getIsarchived() {
return $this->isarchived;
}
public function getArchivestatus() {
return $this->archivestatus;
}
public function setIsarchived($isarchived) {
$this->isarchived = $isarchived;
return $this;
}
public function setArchivestatus($archivestatus) {
$this->archivestatus = $archivestatus;
return $this;
}
}
Found this not sure if it will help though (http://tocacar.com/2013/01/25/doctrine2-object-introspection/)
To get an array of metadata:
$cmf = $em->getMetadataFactory();
$metadata = $cmf->getMetadataFor(\AppBundle\Entity\Inventory::class);
//Doctrine\ORM\Mapping\ClassMetadata instance
//as array:
$metadata = (array) $metadata;
To get the inversed information:
$metadata->getAssociationMapping('companyId')['inversedBy'];
//as array
$metadata['associationMappings']['companyId']['inversedBy'];
You can find more info on the docs.