0

I have categories structure (using Gedmo Nested Tree extension for Doctrine2) like in the example: https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md#tree-entity-example

The question is how to display all the tree as a table like this:

<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>

Another words, I need to get the tree as a plain list with Level param in 1 query. I found a way to get the list only as array (getNodesHierarchy), but I need to have it as a collection like if I called findAll()

Alexey Kosov
  • 3,010
  • 2
  • 23
  • 32

1 Answers1

0

Found the solution:

class CategoryRepository extends NestedTreeRepository
{
    public function getTreeList()
    {
        return $this->getNodesHierarchyQuery()->getResult();
    }
}
Alexey Kosov
  • 3,010
  • 2
  • 23
  • 32