2012-02-14 94 views
0

我正在尝试将缓存注入到使用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; 
} 

但没有任何反应。我期望脚本死掉,但由于某种原因,这个函数从未被执行。我相信我做错了什么,但是有人可以解释如何在模块中注入缓存(或其他任何对象)?

回答

0

这个问题现在在Zend邮件列表上得到解答。 See here

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