當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::getHeader方法代碼示例

本文整理匯總了PHP中Bluz\Proxy\Request::getHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getHeader方法的具體用法?PHP Request::getHeader怎麽用?PHP Request::getHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bluz\Proxy\Request的用法示例。


在下文中一共展示了Request::getHeader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: preDispatch

 /**
  * {@inheritdoc}
  *
  * @param string $module
  * @param string $controller
  * @param array $params
  * @return void
  */
 protected function preDispatch($module, $controller, $params = array())
 {
     // example of setup default title
     Layout::title("Bluz Skeleton");
     // apply "remember me" function
     if (!AuthProxy::getIdentity()) {
         if ($token = Request::getHeader('Bluz-Token')) {
             Auth\Table::getInstance()->authenticateToken($token);
         } elseif (!empty($_COOKIE['rToken']) && !empty($_COOKIE['rId'])) {
             // try to login
             try {
                 Auth\Table::getInstance()->authenticateCookie($_COOKIE['rId'], $_COOKIE['rToken']);
             } catch (AuthException $e) {
                 $this->getResponse()->setCookie('rId', '', 1, '/');
                 $this->getResponse()->setCookie('rToken', '', 1, '/');
             }
         }
     }
     parent::preDispatch($module, $controller, $params);
 }
開發者ID:bluzphp,項目名稱:skeleton,代碼行數:28,代碼來源:Bootstrap.php

示例2: methodGet

 /**
  * Method HEAD and GET
  *
  * @return mixed
  */
 public function methodGet()
 {
     if (!empty($this->primary)) {
         // @throws NotFoundException
         $result = $this->readOne($this->primary);
         return [$result];
     } else {
         // setup default offset and limit - safe way
         $offset = isset($this->params['offset']) ? $this->params['offset'] : 0;
         $limit = isset($this->params['limit']) ? $this->params['limit'] : 10;
         if ($range = Request::getHeader('Range')) {
             list(, $offset, $last) = preg_split('/[-=]/', $range);
             // for better compatibility
             $limit = $last - $offset;
         }
         return $this->readSet($offset, $limit, $this->params);
     }
 }
開發者ID:dezvell,項目名稱:mm.local,代碼行數:23,代碼來源:Rest.php

示例3: function

 * @accept JSON
 * @method GET
 *
 * @param  \Bluz\Crud\Table $crud
 * @param  mixed $primary
 * @return array
 */
return function ($crud, $primary) {
    if (!empty($primary)) {
        // @throws NotFoundException
        return [$crud->readOne($primary)];
    } else {
        $params = Request::getParams();
        // setup default offset and limit - safe way
        $offset = Request::getParam('offset', 0);
        $limit = Request::getParam('limit', 10);
        if ($range = Request::getHeader('Range')) {
            list(, $offset, $last) = preg_split('/[-=]/', $range);
            // for better compatibility
            $limit = $last - $offset;
        }
        Response::setStatusCode(206);
        $total = 0;
        $result = $crud->readSet($offset, $limit, $params, $total);
        if (sizeof($result) < $total) {
            Response::setStatusCode(206);
            Response::setHeader('Content-Range', 'items ' . $offset . '-' . ($offset + sizeof($result)) . '/' . $total);
        }
        return $result;
    }
};
開發者ID:bluzphp,項目名稱:skeleton,代碼行數:31,代碼來源:get.php


注:本文中的Bluz\Proxy\Request::getHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。