/**
* getter method, basically same as offsetGet().
*
* This method can be called from an object of type Zend_Registry, or it
* can be called statically. In the latter case, it uses the default
* static instance stored in the class.
*
* @param string $index - get the value associated with $index
* @return mixed
* @throws Zend_Exception if no entry is registerd for $index.
*/
public static function get($index)
{
$instance = self::getInstance();
if (!$instance->offsetExists($index))
{
if ($instance->lazyLoad($index, $return))
{
return $return;
}
else
{
throw new Zend_Exception("No entry is registered for key '$index'");
}
}
return $instance->offsetGet($index);
}
...
public static function getDb()
{
return self::get('db');
}
...
这是取自Xenforo/Application.php,虽然注释很清楚,但还是有一些疑问:
$instance = self::getInstance();
这条线在这里是什么意思?$instance->lazyLoad;
找不到这个方法的声明:lazyLoad,也是Zend文件吗?$instance->offsetGet($index)
,我在SPL.php中看到了它的声明,是:
public function offsetGet ($index) {}
,但是在{}里面是空的,那么这个函数是怎么实现的呢?