/**
* 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, Хотя комментарий ясен, но все еще есть некоторые вопросы:пытаются понять некоторые функции, связанные с ZEND
$instance = self::getInstance();
что это значит здесь эта линия?$instance->lazyLoad;
Я не смог найти объявление этого метода: lazyLoad, это также файл Zend?$instance->offsetGet($index)
, я видел его заявление в SPL.php, это:
public function offsetGet ($index) {}
, но он пустой внутри {}, так как же эта функция?
'get' берется из Zend/registry.php – danronmoon