[英]How to decorate PageAdminController in SonataPageBundle v4.x
我正在尝试在其 4.x 版本的项目中使用 SonataPageBundle。
我看到自第 3 版以来,许多类都已成为最终类,例如PageAdminController 。
我曾经扩展这个 PageAdminController 来定制它的行为。 现在,这不能再做了。 请问如何在没有 inheritance 的情况下自定义 controller (或其他最终类)?
我尝试使用 Symfony 装饰,但似乎没有奏效。 这是我的代码:
服务.yaml
App\Controller\Page\PageAdminController:
decorates: 'sonata.page.controller.admin.page'
public: true
tags:
- 'container.service_subscriber'
calls:
- [ setContainer, [ "@service_container" ] ]
我的页面管理员控制器
use Sonata\PageBundle\Controller\PageAdminController as SonataPageAdminController;
class PageAdminController extends CRUDController
{
public function __construct(
private SonataPageAdminController $basePageAdminController,
)
{
}
// I redefined all the needed methods the same way as this one
public function batchActionSnapshot(ProxyQueryInterface $query): RedirectResponse
{
return $this->basePageAdminController->batchActionSnapshot($query);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.