NestedSet Tree メソッドを使用して、ライブラリのツリーを構築しています。すべての最下位ライブラリにも一連のオブジェクトがあります。
これは、私の Library Entity クラスで次のように定義されています。
/**
* @ORM\OneToMany(targetEntity="Object", mappedBy="library")
*/
private $objects;
私の Object Entity クラスには、次のものがあります。
/**
* @ORM\ManyToOne(targetEntity="Library", inversedBy="objects")
**/
private $library;
そして最後に、ツリーを取得します
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository('AcmeDemoBundle:Library');
$arrayTree = $repo->childrenHierarchy();
childrenHierarchy() を実行すると、ツリーが取得されますが、Objects 変数はありません。例:
[0] => Array
(
[id] => 1
[name] => Foo
[left] => 1
[level] => 0
[right] => 6
[root] => 1
[__children] => Array
(
[0] => Array
(
[id] => 2
[name] => Bar
[left] => 2
[level] => 1
[right] => 3
[root] => 1
[__children] => Array
(
)
)