项目作者: redco

项目描述 :
This bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin
高级语言: HTML
项目地址: git://github.com/redco/sonata-admin-tree-bundle.git
创建时间: 2016-07-24T15:30:06Z
项目社区:https://github.com/redco/sonata-admin-tree-bundle

开源协议:MIT License

下载


sonata-admin-tree-bundle

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

  1. composer require redcode/tree-bundle

Register the bundle in your app kernel ./app/AppKernel.php

  1. class AppKernel extends Kernel
  2. {
  3. public function registerBundles()
  4. {
  5. $bundles = array(
  6. ...
  7. new RedCode\TreeBundle\RedCodeTreeBundle(),
  8. );
  9. ...
  10. }
  11. }

Add the following lines to the routing file ./app/config/routing.yml

  1. redcode_tree:
  2. resource: "@RedCodeTreeBundle/Resources/config/routing.yml"
  3. prefix: /admin

For the entity with enabled Gedmo Nested Set follow these steps:

Extend Admin class from \RedCode\TreeBundle\Admin\AbstractTreeAdmin

  1. class SubjectAdmin extends AbstractTreeAdmin
  2. {
  3. ...
  4. }

Extend AdminController from \RedCode\TreeBundle\Controller\TreeAdminController

  1. class SubjectAdminController extends TreeAdminController
  2. {
  3. ...
  4. }

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.

  1. app.admin.subject:
  2. class: AppBundle\Admin\SubjectAdmin
  3. arguments: [~, AppBundle\Entity\Subject, AppBundle:SubjectAdmin, 'word']
  4. tags:
  5. - {name: sonata.admin, manager_type: orm, group: Search, label: Subject}

How it looks like

redcode/tree-bundle