本文整理汇总了PHP中ClassRegistry::objects方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassRegistry::objects方法的具体用法?PHP ClassRegistry::objects怎么用?PHP ClassRegistry::objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassRegistry
的用法示例。
在下文中一共展示了ClassRegistry::objects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
/**
* Loads and instantiates models required by this controller.
* If Controller::persistModel; is true, controller will cache model instances on first request,
* additional request will used cached models.
* If the model is non existent, it will throw a missing database table error, as Cake generates
* dynamic models for the time being.
*
* @param string $modelClass Name of model class to load
* @param mixed $id Initial ID the instanced model class should have
* @return mixed true when single model found and instance created error returned if models not found.
* @access public
*/
public function loadModel($modelClass = null, $id = null)
{
if ($modelClass === null) {
$modelClass = $this->modelClass;
}
$cached = false;
$object = null;
$plugin = null;
if ($this->uses === false) {
if ($this->plugin) {
$plugin = $this->plugin . '.';
}
}
list($plugin, $modelClass) = pluginSplit($modelClass, true, $plugin);
if ($this->persistModel === true) {
$cached = $this->_persist($modelClass, null, $object);
}
if ($cached === false) {
$this->modelNames[] = $modelClass;
$this->{$modelClass} = ClassRegistry::init(array('class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id));
if (!$this->{$modelClass}) {
return $this->cakeError('missingModel', array(array('className' => $modelClass, 'webroot' => '', 'base' => $this->base)));
}
if ($this->persistModel === true) {
$this->_persist($modelClass, true, $this->{$modelClass});
$this->_persist($modelClass . 'registry', true, ClassRegistry::objects(), 'registry');
}
} else {
$this->_persist($modelClass . 'registry', true, $object, 'registry');
$this->_persist($modelClass, true, $object);
$this->modelNames[] = $modelClass;
}
}