disable action in sonata admin bundle CRUD

Bartosz Rychlicki picture Bartosz Rychlicki · Aug 17, 2013 · Viewed 13.9k times · Source

IS there a simple way to disable some CRUD actions for given admin class? E.g. I just want a list of users added via front-end without the option to manually add them.

Answer

rpg600 picture rpg600 · Aug 17, 2013

In your admin class :

protected function configureRoutes(RouteCollection $collection)
{
    // to remove a single route
    $collection->remove('delete');
    // OR remove all route except named ones
    $collection->clearExcept(array('list', 'show'));
}

Also use routeCollection at top of admin class

use Sonata\AdminBundle\Route\RouteCollection;

Docs : http://sonata-project.org/bundles/admin/master/doc/reference/routing.html#removing-a-single-route