2017-07-18 3 views
0

仮想プロパティを使用してリスナーに動作していない「たくさん」 をリンクしかし、私は取得するとき私は "BailProprietaireは" lot.orm.ymlで多対多の私は、エンティティ「BailProprietaire」を取得する場合、私は実体を参照してください</p> <p>「ロット」と「BailProprietaire」beetween多対多の関係を持っている

をリンクされたエンティティが表示されていない実体 "ロット" は、私が持っている:bailProprietaire.orm.ymlで

AppBundle\Entity\Lot: 
type: entity 
repositoryClass: AppBundle\Repository\LotRepository 
table: lot 
.... 
.... 
manyToMany: 
    bauxProprietaire: 
     targetEntity: BailProprietaire 
     mappedBy: lots 

を、私は持っている:

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: { } 

私は何かが見逃していますか?

おかげ

EDIT:BailProprietaire.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; 
    } 


} 

Lot.php

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:実際には、それはではなく動作しますリスナー

実際、私は "たくさん"を得るときにエンティティ "BailProprietaire"を参照します。しかし、データをフラッシュするとき、私はリスナを持っています。このリスナーでは、私が持っている "Lot.php" の仮想propertie呼び出す:

if (!empty($this->bauxProprietaire)) { 
     .... 
    } else { 
     .... 
    } 

しかします$ this-> bauxProprietaireは常に[OK]を

+0

はあなたが私達にあなたのPHPのエンティティコードを表示することができます動作しますなぜ私は理解していませんか? –

答えて

0

空ですが、私は問題を発見しました。

私はの$ this - > bauxProprietaireを行うと、私は「教義\ ORM \ PersistentCollection」を持っていますが、私は、このオブジェクトでコレクションを見ると、0要素 enter image description here

があるが、私はの$ this - を行う場合> bauxProprietaire->のtoArray()、私は私の関係を参照

それは

関連する問題