简体   繁体   中英

Use doctrine CRUD in Sonata Admin

I generated CRUD with command:

doctrine:generate:crud --entity=TeoBlogBundle

and i have simply CRUD for my Bundle. I would like use this CRUD in Sonata Admin Bundle, but I never found example for this.

I must create BlogAdmin class for my Bundle? Is not possible to import my CRUD? I want use my BlogBundle only in backend - SonataAdmin, where i have others bundles to manage my site. I would like add this to menu Sonata.

Sonata Admin bundle allow to extend CRUD controller and then you can use it without generating doctrine crud. You must create BlogAdmin Bundle. Use following code:

namespace Tutorial\BlogBundle\Controller;

use Sonata\AdminBundle\Controller\CRUDController as Controller;

class CommentAdminController extends Controller
{

}

Or you can suppress the need to create the admin controller. Here's example syntax for config.yml. The null below is required to accomplish this.

my.listing.admin.resource:
   class: My\ExampleBundle\Admin\ResourceAdmin
   tags:
     - { name: sonata.admin, manager_type: orm, group: "Resource", label: "My Resource" }
   arguments: [null, My\ExampleBundle\Entity\Resource, null ]
                                                         ^
                                                         |
---------------------------------------------------------+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM