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


PHP Request::getRequestUri方法代码示例

本文整理汇总了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();
 }
开发者ID:dezvell,项目名称:skeleton,代码行数:21,代码来源:Bootstrap.php

示例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);
 }
开发者ID:Kit-kat1,项目名称:custom-bluz-app,代码行数:97,代码来源:Application.php

示例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>';
};
开发者ID:dezvell,项目名称:mm.local,代码行数:31,代码来源:Ahref.php

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

示例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;
};
开发者ID:dezvell,项目名称:skeleton,代码行数:31,代码来源:route-static.php


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