5. Defining the CRUD controller

A crud controller class is just an empty class with no methods. However, you can add new actions or overwrite the default CRUD actions to suit your application.

Note

The controller declaration is optional, if none is defined, then the AdminBundle will use the CRUDController.

Just create 3 files inside the Controller directory

5.1. CommentAdminController

<?php
// src/Tutorial/BlogBundle/Controller/CommentAdminController.php

namespace Tutorial\BlogBundle\Controller;

use Sonata\AdminBundle\Controller\CRUDController as Controller;

class CommentAdminController extends Controller
{

}

5.2. PostAdminController

<?php
// src/Tutorial/BlogBundle/Controller/PostAdminController.php
namespace Tutorial\BlogBundle\Controller;

use Sonata\AdminBundle\Controller\CRUDController as Controller;

class PostAdminController extends Controller
{

}

5.3. TagAdminController

<?php
// src/Tutorial/BlogBundle/Controller/TagAdminController.php
namespace Tutorial\BlogBundle\Controller;

use Sonata\AdminBundle\Controller\CRUDController as Controller;

class TagAdminController extends Controller
{

}

When the controller class is instantiated, the admin class is attached to the controller.

Let’s create the admin classes ...

Table Of Contents

Previous topic

4. Defining the routing

Next topic

6. Defining admin class

This Page