teoagru
teoagru

Reputation: 23

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.

Upvotes: 2

Views: 1261

Answers (2)

mhodges2
mhodges2

Reputation: 1

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 ]
                                                         ^
                                                         |
---------------------------------------------------------+

Upvotes: 0

Petar
Petar

Reputation: 101

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
{

}

Upvotes: 1

Related Questions