我正在使用 NestedSet Tree 方法来构建库树。每个底层库也有一组对象。
这是在我的库实体类中定义的:
/**
* @ORM\OneToMany(targetEntity="Object", mappedBy="library")
*/
private $objects;
在我的对象实体类中,我有:
/**
* @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
(
)
)