Reputation: 199
I'm trying to following this section on Sonata's official website to add a custom controller to my menu.
What I have is a working controller;
class HelloController extends Controller {
/**
*
* @Template()
* @param type $name
* @return type
*/
public function indexAction($name)
{
$admin_pool = $this->get('sonata.admin.pool');
return array(
'admin_pool' => $admin_pool,
'name' => $name
);
}
}
I have registered the controller as a service in my services.yml file;
app.hello_controller:
class: AppBundle\Controller\HelloController
And finally I've added the controller route as an item to the menu;
sonata_admin:
dashboard:
groups:
Monitoring:
items:
- app.hello_controller
But now I'm getting the error;
An exception has been thrown during the rendering of a template ("Admin service "app.hello_controller" not found in admin pool.") in SonataAdminBundle:Core:add_block.html.twig at line 5.
Can somebody please tell me what I'm missing, to add menu items this way?
Upvotes: 0
Views: 1044
Reputation: 2745
You need to fix your config. In you example you are adding an admin service with the service id app.hello_controller
to the menu.
What you need to do is add the following config to add one specific route / action from the controller:
config.yml
sonata_admin:
dashboard:
groups:
Monitoring:
items:
- route: your_route_name
label: Your Menu Item Label
Upvotes: 2