本文整理汇总了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);
}
示例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);
}
}
示例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;
}
};