简体   繁体   中英

How to decorate final class Sonata\PageBundle\Admin\BlockAdmin

Since Sonata\PageBundle\Admin\BlockAdmin is @final i should not extend from it. In UPGRADE-3x.md i can see that i should use decoration.

I am trying to this by decorating this final class with App\Sonata\PageBundle\Admin\PageAdmin .

services.yaml configuration:

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

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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