New in Symfony 5.1: Simpler service decoration
Service decoration is used in Symfony applications to change the behavior of some service without replacing it entirely. To do that, you need to inject the original service as an argument of the new decorating service. The problem is that the original service no longer exists, so you can't use its original ID.
In previous Symfony versions you needed to use the syntax
decorating service ID
.inner to refer to that service. This quickly becomes cumbersome in YAML/XML
when using PHP classes as service IDs. That's why in Symfony 5.1 we've simplified
this feature to always use
.inner to refer to the original service:
1 2 3 4 5 6 7 8 9 10 11 12 13
# config/services.yaml services: App\Mailer: ~ # Before App\SpecialMailer: decorates: App\Mailer arguments: ['@App\SpecialMailer.inner'] # After App\SpecialMailer: decorates: App\Mailer arguments: ['@.inner']
New in Symfony 5.1: Simpler service decoration symfony.com/blog/new-in-symfony-5-1-simpler-service-decorationTweet this
Become a certified developer! Exams are online and available in all countries.Register Now
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.