Skip to content

This bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin

License

Notifications You must be signed in to change notification settings

da-vinci-studio/sonata-admin-tree-bundle

 
 

Repository files navigation

sonata-admin-tree-bundle

This bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin.

A tree builds itself in asynchronous way. So, 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 install StofDoctrineExtensionsBundle
https://symfony.com/doc/master/bundles/StofDoctrineExtensionsBundle/index.html

Enable Tree Extension
- nested behavior will implement the standard Nested-Set behavior on your Entity
https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md

Install TreeBundle

Install it via composer

composer install redcode/tree-bundle

Register bundle in kernel ./app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new RedCode\TreeBundle\RedCodeTreeBundle(),
        );
        ...
    }
}

Add 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 do following 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 admin as a service, provider fourth argument - 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}

How it looks like

redcode/tree-bundle

About

This bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 59.9%
  • PHP 40.1%