-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Labels
DependencyInjectionFeatureHelp wantedIssues and PRs which are looking for volunteers to complete them.Issues and PRs which are looking for volunteers to complete them.
Description
Description
It would be nice to handle decorations on non existent services by either throwing the service not found exception or just silently ignoring the service all together, similar to how missing services as parameters are handles.
Example
Imagine having an OptionalBundle with a service OptionalBundle\Services\OptionalService and another Bundle DecoratorBundle that has to decorate the OptionalService if present:
<service id="OptionalBundle\Services\OptionalService" class="OptionalBundle\Services\OptionalService" />
<!-- ... -->
<service id="DecoratorBundle\Service\Decorator\OptionalServiceDecorator" decorates="OptionalBundle\Services\OptionalService" class="DecoratorBundle\Service\Decorator\OptionalServiceDecorator" on-invalid="ignore" />Now in my example I don't have OptionalBundle installed and the DecoratorBundle would be broken. With the new attribute on-invalid with values exception, ignore, null you can control the handling:
exception: default, throw exceptionignore: don't create decoration service at allnull: create decoration service but ifservice.innergets passed as a parameter it will be null -> might need expliciton-invalidattribute on parameter itself.
For YAML declaration I would suggest using the @? syntax as for arguments.
Metadata
Metadata
Assignees
Labels
DependencyInjectionFeatureHelp wantedIssues and PRs which are looking for volunteers to complete them.Issues and PRs which are looking for volunteers to complete them.