0
我宣佈在service.yml一些相關服務,如:Symfony2 - LswMemcacheBundle - 我可以在另一個服務中使用memecache.default服務嗎?
content_helper:
class: Oilproject\ContentBundle\Helper\ContentHelper
arguments: ["@doctrine.orm.entity_manager", "@memcache.default"]
calls:
- [setMemcache, ["@memcache.default"]]
我的助手類:
private $em;
private $memcache;
public function __construct(\Doctrine\ORM\EntityManager $em) {
$this->em = $em;
$this->memcache = $memcache;
}
public function setMemcache($memcache) {
$this->memcache = $memcache;
return $this;
}
//...
但是,當我打電話
$memcache = $this->memcache;
$contents = $memcache->get($key);
這回
Call to a member function get() on a non-object ...