本文整理匯總了PHP中UrlHelper::uri方法的典型用法代碼示例。如果您正苦於以下問題:PHP UrlHelper::uri方法的具體用法?PHP UrlHelper::uri怎麽用?PHP UrlHelper::uri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UrlHelper
的用法示例。
在下文中一共展示了UrlHelper::uri方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: dispatch
/**
* Finds and loads a Controller for the given http request
* @return boolean
*/
public function dispatch()
{
include_once BOOTSTRAP_FILE;
$this->_domain = $_SERVER['HTTP_HOST'];
$this->_url = $_SERVER['REQUEST_URI'];
$this->_args = $_GET;
$route = $this->findCustomRoute();
if ($route) {
//handle custom route
if ($route->isRedirect()) {
RequestHelper::redirect($route->httpStatus, $route->redirectLocation);
} else {
include CONTROLLER_PATH . $route->controller . '/controller.php';
$template = $route->controller . '/view';
$controller = new page();
$controller->set_view($template);
$controller->set_args($route->pathVariables);
$controller->get();
}
} else {
//custom route not found, map url to filesystem
//auto map subdomains to _subdomain_ folders
$subdomain = str_replace(Config::get('NAKED_DOMAIN'), '', $this->_domain);
$subdomainFolder = "";
if (substr($subdomain, -1) == '.') {
$subdomain = substr($subdomain, 0, -1);
}
if ($subdomain != Config::get('DEFAULT_SUBDOMAIN')) {
//redirect naked domain to default subdomain, if necessary;
if (empty($subdomain)) {
RequestHelper::redirect(UrlHelper::uri($this->_url));
die;
} else {
$subdomainFolder = '_' . $subdomain . '_/';
if (!is_dir(CONTROLLER_PATH . $subdomainFolder)) {
if (is_dir(CONTROLLER_PATH . '_*_/')) {
include CONTROLLER_PATH . '_*_/controller.php';
$template = CONTROLLER_PATH . '_*_/view';
$controller = new page();
$controller->set_view($template);
$controller->set_args(array('subdomain' => $subdomain));
$controller->get();
die;
} else {
$this->throwError('404');
}
}
}
}
//on default subdomain, so continue
$path = UrlHelper::convertUrlToPath($this->_url);
if (empty($path)) {
if (is_dir(CONTROLLER_PATH . $subdomainFolder) && is_readable(CONTROLLER_PATH . $subdomainFolder . 'controller.php')) {
include CONTROLLER_PATH . $subdomainFolder . 'controller.php';
$template = $subdomainFolder . 'view';
} else {
$this->throwError('404');
}
} elseif (is_dir(CONTROLLER_PATH . $subdomainFolder . $path) && is_readable(CONTROLLER_PATH . $subdomainFolder . $path . '/controller.php')) {
include CONTROLLER_PATH . $subdomainFolder . $path . '/controller.php';
$template = $subdomainFolder . $path . DS . 'view';
} elseif (is_readable(CONTROLLER_PATH . $subdomainFolder . $path)) {
$file = CONTROLLER_PATH . $subdomainFolder . $path;
if (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
// return mime type ala mimetype extension
header("Content-type: " . finfo_file($finfo, $file));
finfo_close($finfo);
} elseif (function_exists('mime_content_type')) {
header("Content-type: " . mime_content_type($file));
} else {
header("Content-type: text/plain");
}
readfile($file);
die;
} else {
$this->throwError('404');
return false;
}
$controller = new page();
$controller->set_view($template);
$controller->get();
}
return true;
}