redcode / tree-bundle
This Symfony bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin
Installs: 48 013
Dependents: 0
Suggesters: 0
Security: 0
Stars: 30
Watchers: 6
Forks: 19
Open Issues: 4
Language:HTML
Type:symfony-bundle
Requires
- php: >=5.6.0
- sonata-project/admin-bundle: ^3.1
- stof/doctrine-extensions-bundle: ^1.2
Requires (Dev)
- fabpot/php-cs-fixer: ^1.10
- phpunit/phpunit: ^4.8
- satooshi/php-coveralls: ^0.6.1
This package is not auto-updated.
Last update: 2024-11-12 04:07:09 UTC
README
This bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin.
A tree builds itself in an asynchronous way. Hence, it's quite good for big trees.
Installation
Install requirements
SonataAdminBundle
- the SonataAdminBundle provides an installation article here:
http://symfony.com/doc/current/bundles/SonataAdminBundle/index.html
StofDoctrineExtensionsBundle
- then you need to install StofDoctrineExtensionsBundle
https://symfony.com/doc/master/bundles/StofDoctrineExtensionsBundle/index.html
Enable Tree Extension
- nested behaviour will implement the standard Nested-Set behaviour on your Entity
https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md
Install TreeBundle
Install it via composer
composer require redcode/tree-bundle
Register the bundle in your app kernel ./app/AppKernel.php
class AppKernel extends Kernel { public function registerBundles() { $bundles = array( ... new RedCode\TreeBundle\RedCodeTreeBundle(), ); ... } }
Add the following lines to the routing file ./app/config/routing.yml
redcode_tree: resource: "@RedCodeTreeBundle/Resources/config/routing.yml" prefix: /admin
For the entity with enabled Gedmo Nested Set follow these steps:
Extend Admin class from \RedCode\TreeBundle\Admin\AbstractTreeAdmin
class SubjectAdmin extends AbstractTreeAdmin { ... }
Extend AdminController from \RedCode\TreeBundle\Controller\TreeAdminController
class SubjectAdminController extends TreeAdminController { ... }
When registering the admin as a service, you need to provide a fourth argument - the name of the field that will be shown in the tree.
app.admin.subject: class: AppBundle\Admin\SubjectAdmin arguments: [~, AppBundle\Entity\Subject, AppBundle:SubjectAdmin, 'word'] tags: - {name: sonata.admin, manager_type: orm, group: Search, label: Subject}