简体   繁体   English

如何装饰最终 class Sonata\PageBundle\Admin\BlockAdmin

[英]How to decorate final class Sonata\PageBundle\Admin\BlockAdmin

Since Sonata\PageBundle\Admin\BlockAdmin is @final i should not extend from it.由于Sonata\PageBundle\Admin\BlockAdmin@final我不应该从它扩展。 In UPGRADE-3x.md i can see that i should use decoration.UPGRADE-3x.md中,我可以看到我应该使用装饰。

I am trying to this by decorating this final class with App\Sonata\PageBundle\Admin\PageAdmin .我试图通过用App\Sonata\PageBundle\Admin\PageAdmin装饰这个最终的 class 来实现这一点。

services.yaml configuration: services.yaml配置:

parameters:
    sonata.page.admin.page.class: App\Sonata\PageBundle\Admin\PageAdmin

services:
    Sonata\PageBundle\Admin\PageAdmin:
        alias: sonata.page.admin.page

    App\Sonata\PageBundle\Admin\PageAdmin:
        decorates: Sonata\PageBundle\Admin\PageAdmin

Decorator App\Sonata\PageBundle\Admin\PageAdmin body looks like this (i just invoke all the methods from final class in my decorator): https://gist.github.com/AVAW/910604534684eedb228f71df1d7deb40 Decorator App\Sonata\PageBundle\Admin\PageAdmin body looks like this (i just invoke all the methods from final class in my decorator): https://gist.github.com/AVAW/910604534684eedb228f71df1d7deb40

But i get error:但我得到错误: 在此处输入图像描述

Is there any possible way to decorate this final service or I am doing something wrong?有没有可能的方法来装饰这个最终服务或者我做错了什么?

I am using:我在用:

sonata-project/admin-bundle: 3.107.3
sonata-project/page-bundle: 3.26.0
symfony: 4.4.41

Did you try to remove the alias and directly use the sonata service name in the "decorate"?您是否尝试删除别名并直接使用“装饰”中的奏鸣曲服务名称? like this:像这样:

services:
    App\Sonata\PageBundle\Admin\PageAdmin:
        decorates: 'sonata.page.admin.page'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM