PersistentCollectionに問題があります。PersistentCollectionは初期化されていませんが、SymfonyとDoctrineを使用するデータベース内のデータ
EmdebedDocument Seanceを持っているオブジェクトユーザー(FOSUserbundleユーザークラスを継承)があります。 Seanceにはイベントの配列があります。 私の交霊会クラス:
/**
* @MongoDB\EmbeddedDocument
*/
class Event extends BaseEvent
{
/**
* @var integer
* @MongoDB\Id
*/
protected $id;
/**
* @var \DateTime
* @MongoDB\Field(type="date")
* @Assert\NotNull()
*/
protected $startDate;
/**
* @var \DateTime
* @MongoDB\Field(type="date")
* @Assert\NotNull()
*/
protected $endDate;
は私がして、ユーザからのイベントを与える
/**
* @MongoDB\EmbeddedDocument
*/
class Seance
{
/**
* @MongoDB\Id
*/
protected $id;
/**
* @MongoDB\EmbedMany(targetDocument="Event")
*/
protected $dispos ;
/**
* @MongoDB\Field(type="string")
*/
protected $rayonDeplacement;
/**
* @MongoDB\Field(type="string")
*/
protected $lieu;
/**
* @MongoDB\Field(type="string")
*/
protected $prix;
/**
* @MongoDB\Field(type="string")
*/
protected $nbPersonne;
そして、私のクラスのイベント:彼らは、データベース内のイベントがありながら
$user->getSeance()->getDispos()
この関数は空のPersistentCollectionを返します。 。私は空の私のデータが、ArrayCollectionのでmongoDataフィールドを持っている理由私はunderstant dont't
:私が持っているgetDisposのリターン()メソッドをダンプ
。
ありがとうございました。
こんにちは、ありがとうございます。文書が戻ってくる問題は、ヌル値でヌル水和している問題です。 – Oneill
どうしたらいいのか分かりませんが、 '$ user-> getSeance() - > getDispos() - > first()'が正しい文書を生成するかどうか確認してください。 – malarzm
Okey it resolve私は問題が解決する理由を理解できません。ご協力ありがとうございました ! – Oneill