Doctrine orm Doctrine2嵌套集呈现为带缩进的表
我使用Gedmo嵌套树扩展为Doctrine2创建了categories结构,如示例中所示: 问题是如何将所有树显示为如下表:Doctrine orm Doctrine2嵌套集呈现为带缩进的表,doctrine-orm,nested-sets,doctrine-extensions,Doctrine Orm,Nested Sets,Doctrine Extensions,我使用Gedmo嵌套树扩展为Doctrine2创建了categories结构,如示例中所示: 问题是如何将所有树显示为如下表: <table> <tr> <td>Category-1 name</td> <td>Category-1 other data</td> </tr> <tr> <td>Category-2 name</
<table>
<tr>
<td>Category-1 name</td>
<td>Category-1 other data</td>
</tr>
<tr>
<td>Category-2 name</td>
<td>Category-2 other data</td>
</tr>
<tr>
<td><span class="indent">---</span>Subcategory-2-1 name</td>
<td>Subcategory-2-1 other data</td>
</tr>
<tr>
<td><span class="indent">---</span><span class="indent">---</span>Subcategory-2-1-1 name</td>
<td>Subcategory-2-1-1 other data</td>
</tr>
<tr>
<td>Category-3 name</td>
<td>Category-3 other data</td>
</tr>
</table>
换句话说,我需要在1个查询中以带有levelparam的普通列表的形式获取树。
我找到了一种仅以数组getNodesHierarchy的形式获取列表的方法,但我需要将其作为一个集合,就像调用findAll一样找到了解决方案:
class CategoryRepository extends NestedTreeRepository
{
public function getTreeList()
{
return $this->getNodesHierarchyQuery()->getResult();
}
}