J'ai une relation ManyToMany beetween « Lot » et « BailProprietaire »ManyToMany ne fonctionne pas dans l'auditeur avec la propriété virtuelle
Quand je reçois une entité « BailProprietaire », je vois les entités « lot » liées Mais quand je reçois une entité "Lot", je ne vois pas des entités "BailProprietaire" liée
En lot.orm.yml, j'ai:
AppBundle\Entity\Lot:
type: entity
repositoryClass: AppBundle\Repository\LotRepository
table: lot
....
....
manyToMany:
bauxProprietaire:
targetEntity: BailProprietaire
mappedBy: lots
En bailProprietaire.orm.yml, j'ai:
AppBundle\Entity\BailProprietaire:
type: entity
table: bail_proprietaire
repositoryClass: AppBundle\Repository\BailProprietaireRepository
....
....
manyToMany:
lots:
targetEntity: Lot
inversedBy: bauxProprietaire
fetch: LAZY
joinTable:
name: bail_proprietaire_lots
joinColumns:
bail_id:
referencedColumnName: id
inverseJoinColumns:
lot_id:
referencedColumnName: id
lifecycleCallbacks: { }
voyez-vous quelque chose qui me manque?
grâce
EDIT: Ajouter php entité Code
Lot.php
class Lot
{
/**
* @var integer
*/
private $id;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $bauxProprietaire;
/**
* Constructor
*/
public function __construct()
{
$this->bauxProprietaire = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Add bauxProprietaire
*
* @param \AppBundle\Entity\BailProprietaire $bauxProprietaire
*
* @return Lot
*/
public function addBauxProprietaire(\AppBundle\Entity\BailProprietaire $bauxProprietaire)
{
$this->bauxProprietaire[] = $bauxProprietaire;
return $this;
}
/**
* Remove bauxProprietaire
*
* @param \AppBundle\Entity\BailProprietaire $bauxProprietaire
*/
public function removeBauxProprietaire(\AppBundle\Entity\BailProprietaire $bauxProprietaire)
{
$this->bauxProprietaire->removeElement($bauxProprietaire);
}
/**
* Get bauxProprietaire
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBauxProprietaire()
{
return $this->bauxProprietaire;
}
}
BailProprietaire.php
class BailProprietaire
{
/**
* @var integer
*/
private $id;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $lots;
/**
* Constructor
*/
public function __construct()
{
$this->lots = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Add lot
*
* @param \AppBundle\Entity\Lot $lot
*
* @return BailProprietaire
*/
public function addLot(\AppBundle\Entity\Lot $lot)
{
$this->lots[] = $lot;
return $this;
}
/**
* Remove lot
*
* @param \AppBundle\Entity\Lot $lot
*/
public function removeLot(\AppBundle\Entity\Lot $lot)
{
$this->lots->removeElement($lot);
}
/**
* Get lots
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getLots()
{
return $this->lots;
}
}
EDIT 2: en fait, cela fonctionne, mais pas avec l'auditeur
en fait je vois les entités "BailPropriétaire" quand je reçois un "lot" mais quand je vide les données, j'ai un auditeur. Dans cet auditeur, j'appelle une propriétée virtuelle de "Lot.php" où j'ai:
if (!empty($this->bauxProprietaire)) {
....
} else {
....
}
mais $ this-> bauxProprietaire est toujours vide
Pouvez-vous nous montrer votre code d'entité PHP? –