当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getUri方法代码示例

本文整理汇总了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>';
};
开发者ID:bluzphp,项目名称:framework,代码行数:31,代码来源:Ahref.php

示例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;
 }
开发者ID:bluzphp,项目名称:framework,代码行数:16,代码来源:Router.php

示例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());
 }
开发者ID:bluzphp,项目名称:framework,代码行数:10,代码来源:Response.php

示例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));
     }
 }
开发者ID:bluzphp,项目名称:skeleton,代码行数:27,代码来源:Bootstrap.php


注:本文中的Bluz\Proxy\Request::getUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。