扩展 Sonata 的 PageAdmin 时找不到自定义方法



我们使用Easy Extends来扩展Sonata的页面管理。所以我现在有一个看起来像这样的类:

class PageAdmin extends BasePageAdmin
{
    public function configureRoutes(RouteCollection $collection)
    {
        parent::configureRoutes($collection);
        $collection->add( 'send_page_emails', '/admin/send-page-emails');
    }
    ...
}

。我的自定义PageAdminController类包括以下函数:

protected function sendPageEmailsAction()
{
    die('Here I am!');
}

当我尝试重定向到我的新操作时,问题就来了。我得到以下信息:

调用未定义的方法 Sonata\AdminBundle\Controller\CRUDController::sendPageEmailAction

如何让应用程序查找我的操作的正确位置?

===

编辑:这是admin.yml的相关部分。

sonata.page.admin.page:
    class: ApplicationSonataPageBundleAdminPageAdmin
    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']]

在管理控制器中,操作方法应该是公开的,不受保护,否则Sonata将无法找到您的操作方法:

<?php
namespace ApplicationSonataPageBundleController;
use SonataAdminBundleControllerCRUDController;
class PageAdminController extends CRUDController
{
   public function sendPageEmailsAction()
   {
       // your code here
   }
}

相关内容

  • 没有找到相关文章

最新更新