Dependency injection 向模块注入缓存

Dependency injection 向模块注入缓存,dependency-injection,zend-framework2,Dependency Injection,Zend Framework2,我正在尝试使用module.config.php将缓存注入模块,但运气不好。我的module.config.php如下所示 return array( 'di' => array( 'instance' => array( 'AssetLoader\Module' => array( 'parameters' => array( 'cache'

我正在尝试使用module.config.php将缓存注入模块,但运气不好。我的module.config.php如下所示

return array(
    'di' => array(
        'instance' => array(
            'AssetLoader\Module' => array(
                'parameters' => array(
                    'cache'       => 'Zend\Cache\Storage\Adapter\Filesystem',
                ),
            ),
        ),
    ),
);
在我的Module.php中

public function setCache(\Zend\Cache\Storage\Adapter\Filesystem $cache)
{
    die(__FUNCTION__);
    $this->cache = $cache;
}

但什么也没发生。我希望脚本会死,但由于某种原因,这个函数从未执行过。我肯定我做错了什么,但有人能解释一下如何将缓存(或任何其他对象)注入模块吗

这个问题现在在Zend邮件列表中得到了回答。

Matthew指出模块类并没有从定位器中取出,所以不能使用DI向模块注入资源。请查看链接以了解它是如何完成的