docs icon indicating copy to clipboard operation
docs copied to clipboard

Explain how multiple modules can decorate same Symfony service

Open matks opened this issue 5 years ago • 0 comments

    foo:
        class: App\Foo
        arguments: ['@router']
        public: true

    foo_decorated1:
        class: App\DecorFooOne
        decorates: foo
        arguments: ['@foo_decorated1.inner']
        public: true

    foo_decorated2:
        class: App\DecorFooTwo
        decorates: foo
        arguments: ['@foo_decorated2.inner']
        public: true

Constructor of DecorFooTwo will receive an instance of DecorFooOne, not Foo. Symfony is able to chain decoration links.

This means that if multiple modules decorate the same Core service, all the behaviors will be kept (instead of one module overriding others behaviors).

matks avatar Apr 24 '20 13:04 matks