You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Like in the service container, we should be able to specify on a missing parameter (such in the use of <argument on-invalid="ignore">) that if it doesn't exist, it should be ignored (given a null value).
I don't agree with this. Services can be missing due to optional dependencies, but parameters should never be relied on if they come from a third party package. If you want to expose parameters, make sure they are always define, but (e.g) setting arguments of service constructors should be done by config and dependency injection rather than injecting a parameter.
When it comes to your AppBundle, you can just define the parameters yourself and make sure they always exist. Personally I only define them in parameters.yml if they differ per environment.
I agree with @iltar on this. You can always provide defaults for your parameters, or use semantic configuration. It's much easier to understand what's going on this way.
Anyway, adding an argument to a method annotated with @api is not allowed (see our BC promise), so I'll need to close this one.
Like in the service container, we should be able to specify on a missing parameter (such in the use of
<argument on-invalid="ignore">
) that if it doesn't exist, it should be ignored (given a null value).Basically, this is adding a new parameter to the
get
method of theParameterBag
(in https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php#L89), and messing with the dumpers so that if there is the right attribute (on-invalid
?), it should be able to be ignored.To keep BC, and also to have a default mechanism, like in the service container, it should throw the exception if it is missing.
The text was updated successfully, but these errors were encountered: