本文整理汇总了PHP中Bluz\Proxy\Request::getRequestUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getRequestUri方法的具体用法?PHP Request::getRequestUri怎么用?PHP Request::getRequestUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bluz\Proxy\Request
的用法示例。
在下文中一共展示了Request::getRequestUri方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: denied
/**
* Denied access
* @throws ForbiddenException
* @return void
*/
public function denied()
{
// add messages make sense only if presentation is not json, xml, etc
if (!$this->getResponse()->getPresentation()) {
Messages::addError('You don\'t have permissions, please sign in');
}
// redirect to login page
if (!$this->user()) {
// save URL to session and redirect make sense if presentation is null
if (!$this->getResponse()->getPresentation()) {
Session::set('rollback', Request::getRequestUri());
$this->redirectTo('users', 'signin');
}
}
throw new ForbiddenException();
}
示例2: doProcess
/**
* Do process
* @return void
*/
protected function doProcess()
{
Logger::info("app:process:do");
$module = Request::getModule();
$controller = Request::getController();
$params = Request::getAllParams();
// try to dispatch controller
try {
// get reflection of requested controller
$controllerFile = $this->getControllerFile($module, $controller);
$reflection = $this->reflection($controllerFile);
// check header "accept" for catch JSON(P) or XML requests, and switch presentation
// it's some magic for AJAX and REST requests
if ($produces = $reflection->getAccept() and $accept = $this->getRequest()->getAccept()) {
// switch statement for $accept
switch ($accept) {
case Request::ACCEPT_HTML:
// with layout
// without additional presentation
break;
case Request::ACCEPT_JSON:
$this->useJson();
break;
case Request::ACCEPT_JSONP:
$this->useJsonp();
break;
case Request::ACCEPT_XML:
$this->useXml();
break;
default:
// not acceptable MIME type
throw new NotAcceptableException();
break;
}
}
// check call method(s)
if ($reflection->getMethod() && !in_array(Request::getMethod(), $reflection->getMethod())) {
throw new NotAllowedException(join(',', $reflection->getMethod()));
}
// check HTML cache
if ($reflection->getCacheHtml() && Request::getMethod() == Request::METHOD_GET) {
$htmlKey = 'html:' . $module . ':' . $controller . ':' . http_build_query($params);
if ($cachedHtml = Cache::get($htmlKey)) {
Response::setBody($cachedHtml);
return;
}
}
// dispatch controller
$dispatchResult = $this->dispatch($module, $controller, $params);
} catch (RedirectException $e) {
Response::setException($e);
if (Request::isXmlHttpRequest()) {
// 204 - No Content
Response::setStatusCode(204);
Response::setHeader('Bluz-Redirect', $e->getMessage());
} else {
Response::setStatusCode($e->getCode());
Response::setHeader('Location', $e->getMessage());
}
return null;
} catch (ReloadException $e) {
Response::setException($e);
if (Request::isXmlHttpRequest()) {
// 204 - No Content
Response::setStatusCode(204);
Response::setHeader('Bluz-Reload', 'true');
} else {
Response::setStatusCode($e->getCode());
Response::setHeader('Refresh', '0; url=' . Request::getRequestUri());
}
return null;
} catch (\Exception $e) {
Response::setException($e);
// cast to valid HTTP error code
// 500 - Internal Server Error
$statusCode = 100 <= $e->getCode() && $e->getCode() <= 505 ? $e->getCode() : 500;
Response::setStatusCode($statusCode);
$dispatchResult = $this->dispatch(Router::getErrorModule(), Router::getErrorController(), array('code' => $e->getCode(), 'message' => $e->getMessage()));
}
if ($this->hasLayout()) {
Layout::setContent($dispatchResult);
$dispatchResult = Layout::getInstance();
}
if (isset($htmlKey, $reflection)) {
// @TODO: Added ETag header
Cache::set($htmlKey, $dispatchResult(), $reflection->getCacheHtml());
Cache::addTag($htmlKey, $module);
Cache::addTag($htmlKey, 'html');
Cache::addTag($htmlKey, 'html:' . $module);
Cache::addTag($htmlKey, 'html:' . $module . ':' . $controller);
}
Response::setBody($dispatchResult);
}
示例3: function
*
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
/**
* @namespace
*/
namespace Bluz\View\Helper;
use Bluz\View\View;
use Bluz\Proxy\Request;
use Bluz\Proxy\Translator;
return function ($text, $href, array $attributes = []) {
// if href is settings for url helper
if (is_array($href)) {
$href = $this->url(...$href);
}
// href can be null, if access is denied
if (null === $href) {
return '';
}
if ($href == Request::getRequestUri()) {
if (isset($attributes['class'])) {
$attributes['class'] .= ' on';
} else {
$attributes['class'] = 'on';
}
}
$attributes = $this->attributes($attributes);
return '<a href="' . $href . '" ' . $attributes . '>' . Translator::translate($text) . '</a>';
};
示例4: getCleanUri
/**
* Get the request URI without baseUrl
*
* @return string
*/
public function getCleanUri()
{
if ($this->cleanUri === null) {
$uri = parse_url(Request::getRequestUri());
$uri = $uri['path'];
if ($this->getBaseUrl() && strpos($uri, $this->getBaseUrl()) === 0) {
$uri = substr($uri, strlen($this->getBaseUrl()));
}
$this->cleanUri = $uri;
}
return $this->cleanUri;
}
示例5: function
* Example of static route
*
* @author Anton Shevchuk
* @created 12.06.12 13:08
*/
namespace Application;
use Bluz\Proxy\Layout;
use Bluz\Proxy\Request;
return function () use($view) {
/**
* @var Bootstrap $this
* @var \Bluz\View\View $view
*/
Layout::breadCrumbs([Layout::ahref('Test', ['test', 'index']), 'Routers Examples']);
$uri = Request::getRequestUri();
$module = Request::getModule();
$controller = Request::getController();
echo <<<CODE
<h4>URL: {$uri}</h4>
<h4>Route: {$module}/{$controller}</h4>
<pre>
/**
* @route /static-route/
* @route /another-route.html
* @return \\closure
*/
</pre>
CODE;
return false;
};