I
I
Ilya Lesnykh2010-12-08 11:00:05
Zend Framework
Ilya Lesnykh, 2010-12-08 11:00:05

How to get a cache object inside a model in ZF?

In Zend Framework , how can you get a reference to the Zend_Cache object (created in bootstrap by the __initCache() method ) from inside the model without passing a reference to it to the constructor? For example, from inside the controller, it's easy:

$bootstrap = $this->getInvokeArg( 'bootstrap' );
$cache = $bootstrap->getResource( 'Cache' );

PS: do not offer the option with Zend_Registry.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zizop, 2011-01-08
@Aliance

This is how you can:

$cache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('Cache');

Checked on 1.11.0dev. Works!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question