本文整理汇总了PHP中ClassRegistry::load方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassRegistry::load方法的具体用法?PHP ClassRegistry::load怎么用?PHP ClassRegistry::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassRegistry
的用法示例。
在下文中一共展示了ClassRegistry::load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
private function dispatch()
{
if ($this->arguments["command"] == "") {
$this->error("can't call empty command");
}
$fileName = "{$this->arguments['script']}_{$this->arguments['command']}";
$className = Inflector::camelize($fileName);
if ($command =& ClassRegistry::load($className, "Command")) {
if (can_call_method($command, "execute")) {
call_user_func_array(array($command, "execute"), $this->arguments["params"]);
} else {
$this->error("can't execute command {$className}");
}
} else {
$this->error("command {$className} not found");
}
}
示例2: dispatch
/**
* Chama o controller e a action solicitadas pela URL.
*
* @return mixed Instância do novo controller ou falso em caso de erro
*/
public function dispatch()
{
$path = Mapper::parse();
$path["controller"] = Inflector::hyphenToUnderscore($path["controller"]);
$path["action"] = Inflector::hyphenToUnderscore($path["action"]);
$controller_name = Inflector::camelize($path["controller"]) . "Controller";
if ($controller =& ClassRegistry::load($controller_name, "Controller")) {
if (!can_call_method($controller, $path['action']) && !App::path("View", "{$path['controller']}/{$path['action']}.{$path['extension']}")) {
$this->error("missingAction", array("controller" => $path["controller"], "action" => $path["action"]));
return false;
}
} else {
if (App::path("View", "{$path['controller']}/{$path['action']}.{$path['extension']}")) {
$controller =& ClassRegistry::load("AppController", "Controller");
} else {
$this->error("missingController", array("controller" => $path["controller"]));
return false;
}
}
$controller->params = $path;
$controller->componentEvent("initialize");
$controller->beforeFilter();
$controller->componentEvent("startup");
if (in_array($path["action"], $controller->methods) && can_call_method($controller, $path["action"])) {
$params = $path["params"];
if (!is_null($path["id"])) {
$params = array_merge(array($path["id"]), $params);
}
call_user_func_array(array(&$controller, $path["action"]), $params);
}
if ($controller->autoRender) {
$controller->render();
}
$controller->componentEvent("shutdown");
echo $controller->output;
$controller->afterFilter();
return $controller;
}
示例3: identify
/**
* Identifica o usuário no banco de dados.
*
* @param array $conditions Condições da busca
* @return array Dados do usuário
*/
public function identify($conditions)
{
$userModel = ClassRegistry::load($this->userModel);
if (!$userModel) {
$this->error("missingModel", array("model" => $this->userModel));
return false;
}
$params = array("conditions" => array_merge($this->userScope, $conditions), "recursion" => is_null($this->recursion) ? $userModel->recursion : $this->recursion);
return $this->user = $userModel->first($params);
}
示例4: loadModel
/**
* Carrega um modelo.
*
* @param string $model Nome do modelo a ser carregado
* @return boolean Verdadeiro se o modelo foi carregado
*/
public function loadModel($model)
{
if (!isset($this->{$model})) {
if ($class =& ClassRegistry::load($model)) {
$this->{$model} = $class;
} else {
$this->error("missingModel", array("model" => $model));
return false;
}
}
return true;
}
示例5: loadModels
/**
* Carrega todos os models associados ao controller.
*
* @return boolean
*/
public function loadModels()
{
foreach ($this->uses as $model) {
if (!($this->{$model} = ClassRegistry::load($model))) {
$this->error("missingModel", array("model" => $model));
return false;
}
}
return true;
}
示例6: model
/**
* Carrega o Model a ser utilizado na paginação.
*
* @param string $model Model utilizado
* @return object
*/
public function model($model)
{
return $this->model = ClassRegistry::load($model);
}