Problem with container custom function


#1

Hi,

i created a custom function for my container;

$this->app->getContainer()[‘cms.store_location.repository’] = function ($container) {
return new StoreLocationRepository($container[“cms.client”]);
};

The problem is that when i acces $this->app->getContainer()[‘cms.store_location.repository’] for the first time, a StoreLocationRepository instance is created, but all the other time i access $this->app->getContainer()[‘cms.store_location.repository’], no new instance is created.

Is there any cache on the container??

I dont understand why a new instance of StoreLocationRepository is not created every time i access this variable…

Thanks


#2

Have you tried this :
$container = $this->app->getContainer();
$container['cms.store_location.repository’] = function ($c) {
return new StoreLocationRepository($c[“cms.client”]);
};


#3

Hi, it doesnt change anything. this is the same as the code i have