ich eine ManyToMany Beziehung beetween „Lot“ haben und „BailProprietaire“ManyToMany nicht in Zuhörer mit virtuellem Eigentum arbeiten
Wenn ich eine Entität „BailProprietaire“ bekommen, ich sehe die Entitäten „Los“ verknüpft Aber wenn ich ein Unternehmen "Lot", ich sehe nicht, entities "BailProprietaire"
verknüpftIn lot.orm.yml, ich habe:
AppBundle\Entity\Lot:
type: entity
repositoryClass: AppBundle\Repository\LotRepository
table: lot
....
....
manyToMany:
bauxProprietaire:
targetEntity: BailProprietaire
mappedBy: lots
In bailProprietaire.orm.yml, ich habe:
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: { }
Siehst du etwas, was ich vermisse?
dank
EDIT: In PHP-Code Einheit
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: In der Tat, es funktioniert, aber nicht mit der Zuhörer
in der Tat sehe ich die Entitäten "BailProprodaire", wenn ich eine "Menge" bekomme, aber wenn ich Daten flush, habe ich einen Listener. In diesem Hörer, nenne ich eine virtuelle propertie von "Lot.php", wo ich habe:
if (!empty($this->bauxProprietaire)) {
....
} else {
....
}
aber $ this-> bauxProprietaire
können Sie uns Ihre PHP-Code der Einheit zeigen? –