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
Service Id: as.a.name.of.any.choice.refering.to.the.service.class.in.yaml.file
Therefore it is quite easy to get rid of service container usage in the controller class by simply strong-typing arguments of constructor of a controller with the namespace. However, it is not that easy to get rid of service container if the service id is used instead.
From the very first observations I see that there are couple of ways to go and all of them have trade-offs:
It is possible to inject service IDs to constructor of a controller but this would require to turn off autowiring for that particular bundle.
It is possible to create another class that wraps all of such "service ids" and inject it into constructor of a controller via autowiring instead.
It is possible to just:
a) Do not use service container in constructor at all, use autowiring with constructor instead.
b) If the first one (a) is not possible (e.g., pim_catalog.query.product_query_builder_factory_without_permission usage case) then skip using autowiring with constructor completely.
Service classes may be defined in two main ways inside of yaml files:
Therefore it is quite easy to get rid of service container usage in the controller class by simply strong-typing arguments of constructor of a controller with the namespace. However, it is not that easy to get rid of service container if the service id is used instead.
From the very first observations I see that there are couple of ways to go and all of them have trade-offs:
a) Do not use service container in constructor at all, use autowiring with constructor instead.
b) If the first one (a) is not possible (e.g., pim_catalog.query.product_query_builder_factory_without_permission usage case) then skip using autowiring with constructor completely.
It seems that service ids are kind of leftover from the old times when autowiring was not present.
Read more on the entire topic here:
https://symfony.com/doc/3.4/controller/service.html
We need to define a way we do it.
The text was updated successfully, but these errors were encountered: