November 28, 2019 Javier Eguiluz

Improved YAML Syntax for Method Calls¶ Contributed by

Nicolas Grekas

in #33779. Service method calls and setter injection are different ways to call some methods on your classes when building the services for them. In Symfony 4.4 we've improved the YAML syntax to make it more concise and easier to read/write: 1 2 3 4 5 6 7 8 9 # config/services.yaml services: App\Service\MessageGenerator: # ... calls: - - method: setLogger - arguments: - - '@logger' + - setLogger: ['@logger'] Calling to wither methods has been simplified too: 1 2 3 4 5 6 7 8 9 10 # config/services.yaml services: App\Service\MessageGenerator: # ... calls: - - method: withLogger - arguments: - - '@logger' - returns_clone: true + - withLogger: !returns_clone ['@logger']

Better Control of Service Decoration¶ Contributed by

Mathias Arlaud

in #33854. Service decoration is one of the most popular and powerful features of the Symfony Dependency Injection. In Symfony 4.4, we improved it so you can control what happens when the decorated service does not exist: 1 2 3 4 5 # config/services.yaml services : App\NewMailer : decorates : App\Mailer decoration_on_invalid : ignore If the App\Mailer service does not exist, this configuration tells Symfony to ignore the error and remove the App\NewMailer service. The other possible values are exception and null . The exception value tells Symfony to throw a ServiceNotFoundException and it's the default value because it matches the current behavior. The null value makes the decorated service equal to null , so the decorating service must be prepared to handle with null values.