We have used Easy Extends to extend Sonata's Page Admin. So I now have a class that looks like this:
class PageAdmin extends BasePageAdmin
{
public function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
$collection->add( 'send_page_emails', '/admin/send-page-emails');
}
...
}
... and my custom PageAdminController
class includes the following function:
protected function sendPageEmailsAction()
{
die('Here I am!');
}
The problem comes when I try to redirect to my new action. I get the following:
Call to undefined method Sonata\AdminBundle\Controller\CRUDController::sendPageEmailsAction
How can I get the application to look in the correct place for my action?
===
Edit: Here are the relevant parts of admin.yml
.
sonata.page.admin.page:
class: Application\Sonata\PageBundle\Admin\PageAdmin
arguments: [~, '%sonata.page.admin.page.entity%', SonataPageBundle:PageAdmin]
tags:
- { name: sonata.admin, manager_type: orm, group: admin, label: Seiten }
calls:
- [ addChild, ['@sonata.page.admin.block']]
- [ addChild, ['@sonata.page.admin.snapshot']]
- [ setPageManager, ['@sonata.page.manager.page']]
- [ setCacheManager, ['@sonata.cache.manager']]
- [ setSiteManager, ['@sonata.page.manager.site']]
- [ setTranslationDomain, ['SonataPageBundle']]
- [ setTemplate, ['edit', 'ApplicationSonataPageBundle:PageAdmin:edit_duplicate.html.twig']]
- [ setTemplate, ['tree', 'SonataPageBundle:PageAdmin:tree.html.twig']]
- [ setTemplate, ['compose', 'ApplicationSonataPageBundle:PageAdmin:compose.html.twig']]
- [ setTemplate, ['create', 'SonataAdminBundle:CRUD:edit.html.twig']]
- [ setTemplate, ['select_site', 'SonataPageBundle:PageAdmin:select_site.html.twig']]
- [ setTemplate, ['list', 'SonataPageBundle:PageAdmin:list.html.twig']]
- [ setTemplate, ['compose_container_show', 'SonataPageBundle:PageAdmin:compose_container_show.html.twig']]
In the admin controller action method should be public and not protected, otherwise Sonata will not be able to find the method for your action :
<?php
namespace Application\Sonata\PageBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController;
class PageAdminController extends CRUDController
{
public function sendPageEmailsAction()
{
// your code here
}
}