本文整理汇总了PHP中Bluz\Proxy\Request::getUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getUri方法的具体用法?PHP Request::getUri怎么用?PHP Request::getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bluz\Proxy\Request
的用法示例。
在下文中一共展示了Request::getUri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
* @author ErgallM
*
* @var View $this
* @param string $text
* @param string|array $href
* @param array $attributes HTML attributes
* @return string
*/
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 '';
}
$current = Request::getUri()->getPath();
if (Request::getUri()->getQuery()) {
$current .= sprintf('?%s', Request::getUri()->getQuery());
}
if ($href == $current) {
if (isset($attributes['class'])) {
$attributes['class'] .= ' active';
} else {
$attributes['class'] = 'active';
}
}
$attributes = $this->attributes($attributes);
return '<a href="' . $href . '" ' . $attributes . '>' . Translator::translate($text) . '</a>';
};
示例2: getCleanUri
/**
* Get the request URI without baseUrl
*
* @return string
*/
public function getCleanUri()
{
if ($this->cleanUri === null) {
$uri = Request::getUri()->getPath();
if ($this->getBaseUrl() && strpos($uri, $this->getBaseUrl()) === 0) {
$uri = substr($uri, strlen($this->getBaseUrl()));
}
$this->cleanUri = $uri;
}
return $this->cleanUri;
}
示例3: reload
/**
* Reload current page please, be careful to avoid loop of reload
*
* @return void
* @throws ReloadException
*/
public static function reload()
{
self::redirect(Request::getUri());
}
示例4: forbidden
/**
* Denied access
* @param ForbiddenException $exception
* @return \Bluz\Controller\Controller|null
*/
public function forbidden(ForbiddenException $exception)
{
if (AuthProxy::getIdentity()) {
$message = Translator::translate("You don't have permissions to access this page");
} else {
$message = Translator::translate("You don't have permissions, please sign in");
}
// for AJAX and API calls (over JSON)
$jsonOrApi = Request::isXmlHttpRequest() || Request::getAccept([Request::TYPE_HTML, Request::TYPE_JSON]) == Request::TYPE_JSON;
// for guest, for requests
if (!AuthProxy::getIdentity() && !$jsonOrApi) {
// save URL to session and redirect make sense if presentation is null
Session::set('rollback', Request::getUri()->__toString());
// add error notice
Messages::addError($message);
// redirect to Sign In page
$url = Router::getUrl('users', 'signin');
return $this->redirect($url);
} else {
return $this->error(new ForbiddenException($message, 403, $exception));
}
}