Is it possible to reload and autowire a service?
I have a provider class that uses a number of services, these services use autowired configuration loaded from the database.
Looping through the list of providers (with different configuration in DB) results in the same class when I load the service via the containerInterface:
$objSearchProvider = $this->objContainer->get(
$objService->getProvider()->getSearch()
);
The __constructor for the provider is only called the first time in the loop cause it is the same class.
I know there is $this->objContainer->reset() function, but this does not seem to re-autowire the configuration.
Is this even possible?
CodePudding user response:
you need to define your services as not shared if you need a new instance of them every time
https://symfony.com/doc/current/service_container/shared.html