core icon indicating copy to clipboard operation
core copied to clipboard

[General] Use service locators where needed

Open Guite opened this issue 5 years ago • 0 comments

Since Symfony 5.1 it is deprecated to inject the container using autowiring. We currently do that at some places where we need to dynamically access some service instances based on a common interface.

Example: Since symfony/dependency-injection 5.1: The "Psr\Container\ContainerInterface" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.

This happens for several classes, but for different reasons.

One specific subset relates to Zikula\BlocksModule\Api\BlockFactoryApi and Zikula\ContentModule\Helper\ContentDisplayHelper. For these defining a service locator will be the better approach, since this avoids injecting the entire container at all.

https://symfony.com/blog/new-in-symfony-3-3-service-locators https://symfony.com/doc/current/service_container/service_subscribers_locators.html#defining-a-service-locator

Guite avatar Jul 09 '20 06:07 Guite