本文整理匯總了PHP中router::dispatch方法的典型用法代碼示例。如果您正苦於以下問題:PHP router::dispatch方法的具體用法?PHP router::dispatch怎麽用?PHP router::dispatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類router
的用法示例。
在下文中一共展示了router::dispatch方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* run
* the main() to this whole darned thing.
*
* @param array $configuration
*/
public static function run(array $configuration)
{
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', __DIR__);
// having short_open_tag enabled is a dirp
// requirement.
if (!ini_get('short_open_tag')) {
throw new \Exception("The 'short_open_tag' setting MUST be enabled in your php.ini to use dirp, sorry!");
}
// setup the autoloader and the exception handler:
set_exception_handler(array('\\dirp\\app', 'exception_handler'));
static::_autoloader_init();
static::$_cfg = new helper\params($configuration);
static::$_http_request = http\request::factory($_GET, $_POST, $_SERVER);
static::$_http_response = new http\response();
// prepare addons:
if ($addons = static::cfg()->addons) {
addon\manager::load_addons((array) $addons);
}
// the master view is the frame/template around
// the main content area. addons have access to
// it directly through the \dirp\addon\base::master
// method.
static::$_master = view::factory('master/template', array('title' => 'dirp framework', 'body' => '', 'icon' => 'folder_heart.png', 'panels' => addon\event::fire('renderpanels', array('panels' => array()))->panels, 'css' => array(), 'js' => array(), 'head' => array()));
addon\base::set_master_view(static::$_master);
// dispatch the request and figure out what to do with
// the controller's response:
// TO-DO: HEY THE WAY CONTROLLER RETURNS ARE HANDLED IS KINDA FLAKY.
if ($ret = router::dispatch(static::get_request(), static::get_response())) {
if (is_string($ret)) {
if (static::get_request()->is_ajax()) {
static::get_response()->header('content-type', 'text/plain');
static::get_response()->write($ret);
static::get_response()->send();
} else {
static::get_master()->body = $ret;
}
}
}
static::get_response()->write(static::get_master()->render());
addon\event::fire('shutdown', array());
static::get_response()->send();
}
示例2: substr
$path = substr(Path, strlen(Path) - strlen("/")) == "/" ? Path : Path . "/";
$registry->path = $path;
if (!defined('requiresBD')) {
$db = new dbFactory(strtolower(DB_Engine));
} else {
if (requiresBD) {
$db = new dbFactory(strtolower(DB_Engine));
} else {
$db = null;
}
}
$registry->db = $db;
$views = new appviews();
$registry->views = $views;
$themes = new themes();
$registry->themes = $themes;
$session = session::getInstance();
$registry->session = $session;
$cookie = cookie::getInstance();
$registry->cookie = $cookie;
$router = new router();
$registry->router = $router;
$debug = debug::getInstance();
$registry->debug = $debug;
$registry->validateErrors = array();
$router->dispatch();
// Here starts the party
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
示例3: appviews
}
}
$registry->db = $db;
$views = new appviews();
$registry->views = $views;
$themes = new themes();
$registry->themes = $themes;
$session = session::getInstance();
$registry->session = $session;
$cookie = cookie::getInstance();
$registry->cookie = $cookie;
$router = new router();
$registry->router = $router;
$debug = debug::getInstance();
$registry->debug = $debug;
$registry->validateErrors = array();
$router->dispatch(); // Here starts the party
} catch(Exception $e) {
echo $e->getMessage();
exit();
}
?>