本文整理汇总了PHP中core\Config::SetApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::SetApplication方法的具体用法?PHP Config::SetApplication怎么用?PHP Config::SetApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core\Config
的用法示例。
在下文中一共展示了Config::SetApplication方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RUN
public static function RUN($application)
{
try {
$config = Config::SetApplication($application);
if (is_readable($config->dir . 'config.php')) {
require_once $config->dir . 'config.php';
}
} catch (InvalidApplicationException $e) {
echo self::Error($e->getMessage());
return FALSE;
}
$request = Request::getInstance();
// Router em implementação
$router = Router::getInstance();
$route = $router->GetByRequest();
if ($config->onlyroutes && !$route) {
$route = Router::notfound();
}
if ($route) {
$request->controller = $route->controller;
$request->action = $route->action;
$request->params = (object) $route->attributes;
} else {
$request->parseRoute();
}
$class = "\\Controller\\{$request->controller}Controller";
// Retorno caso configuração $outputreturn do controller seja true
$output = '';
try {
if (!class_exists($class)) {
throw new Exception("A URL {$request->uri} é inválida.");
}
$app = new $class();
} catch (Exception $e) {
echo self::Error($e->getMessage());
return FALSE;
}
if (!empty($request->post['mvc:model'])) {
$model = '\\Model\\' . array_remove($request->post, 'mvc:model') . 'Model';
try {
$param = new $model($request->post);
if ($param) {
$param = [$param];
}
} catch (Exception $e) {
$app->setOutput($app->index());
$app->output();
return FALSE;
}
} else {
if (!!$route && count($route->attributes) > 0) {
$param = $route->attributes;
} else {
if (empty($request->lost) && !is_numeric($request->lost)) {
$param = NULL;
} else {
$param = [$request->lost];
}
}
}
try {
$output = $app->execute($param);
} catch (Exception $e) {
echo self::Error($e->getMessage());
return FALSE;
}
if ($app->outputreturn) {
$app->setOutput($output);
}
$app->output();
return TRUE;
}