Current way in Zend.php / Zend_Registry.php:
====================================
$registry = Zend::registry();
$registry = Zend_Registry::getInstance();

I like first one more, since it doesn't bother me with unneeded knowledge about instances.

Alternative new way:
====================================
Zend_Registry::set($key, $value);
Zedn_Registry::get($key);

Same here. Of course, if we had class getters/setters it would be even cooler, but unfortunately you can't do Zend_Registry::$key = $value yet :) AFAIK. I'd still prefer put() to set(), but this is not that important.

With the above get(), the current instance method version of get() in the proposal is replaced with a method that only works on the "global" registry stored in the static class variable. Instance methods for accessors remain the same as for ArrayObject (i.e. inherited as they are now in Registry.php).

We can keep the getInstance() if you wish for those who love patterns and singletons, but this should not be the only way. What I mean is:

static public function put($key, $value) {
        $me = self::getInstance();
        $me[$key] = $value;
}
etc.
--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED]  http://www.zend.com/

Reply via email to