(on Tuesday, 19 January 2010, 06:35 PM +0100):
> >Zend_Registry uses Martin Fowler's Registry pattern. Not singleton.
>
> Even if it does, it still follows the Singleton pattern, too. Or how
> is the Zend_Registry instance accessed?
You can use Zend_Registry either as a singleton, or via discrete
instances.
* Singleton usage:
Zend_Registry::get(), Zend_Registry::set(),
Zend_Registry::getInstance()
* Discrete instances:
$r = new Zend_Registry();
$r['foo'] = 'bar';
$someObject->setRegistry($r);
We use the latter within Zend_Application's base bootstrap class. :)
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
没有评论:
发表评论