Intento usar la extension Tree de para Doctrine, logro agregar a la base de datos esto:
Cita:
pero para recuperar con +----+----------+---------------+-----+-----+-----+------+
| id | menu_id | menu | lft | lvl | rgt | root |
+----+----------+---------------+-----+-----+-----+------+
| 1 | NULL | Food | 1 | 0 | 8 | 1 |
| 2 | 1 | Fruits | 2 | 1 | 3 | 1 |
| 3 | 1 | Vegetables | 4 | 1 | 7 | 1 |
| 4 | 3 | Carrots | 5 | 2 | 6 | 1 |
+----+---------+----------------+-----+-----+-----+------+
4 rows in set
| id | menu_id | menu | lft | lvl | rgt | root |
+----+----------+---------------+-----+-----+-----+------+
| 1 | NULL | Food | 1 | 0 | 8 | 1 |
| 2 | 1 | Fruits | 2 | 1 | 3 | 1 |
| 3 | 1 | Vegetables | 4 | 1 | 7 | 1 |
| 4 | 3 | Carrots | 5 | 2 | 6 | 1 |
+----+---------+----------------+-----+-----+-----+------+
4 rows in set
Código PHP:
$repo = $this->em->getRepository('Application\Entity\Menu');
$food = $repo->findOneByMenu('Food');
echo $repo->childCount($food);
Uncaught exception 'BadMethodCallException' with message 'Undefined method 'childCount'. The method name must start with either findBy or findOneBy!'
en Gedmo\Tree\RepositoryInterface.php si existe el 'metodo childCount'
en mi application.ini integre de esta manera la extension:
Cita:
una ayuda por favor. resources.doctrine.dbal.connections.default.eventS ubscribers[] = "Gedmo\Translatable\TranslatableListener"
resources.doctrine.dbal.connections.default.eventS ubscribers[] = "Gedmo\Tree\TreeListener"
resources.doctrine.dbal.connections.default.eventS ubscribers[] = "Gedmo\Sluggable\SluggableListener"
resources.doctrine.dbal.connections.default.eventS ubscribers[] = "Gedmo\Sortable\SortableListener"
resources.doctrine.dbal.connections.default.eventS ubscribers[] = "Gedmo\Tree\TreeListener"
resources.doctrine.dbal.connections.default.eventS ubscribers[] = "Gedmo\Sluggable\SluggableListener"
resources.doctrine.dbal.connections.default.eventS ubscribers[] = "Gedmo\Sortable\SortableListener"