本文整理汇总了PHP中Cake\Network\Request::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::query方法的具体用法?PHP Request::query怎么用?PHP Request::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Network\Request
的用法示例。
在下文中一共展示了Request::query方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findCursor
public function findCursor(Query $query)
{
$current = $this->request->query('cursor');
$limit = $this->request->query('limit') ?: 10;
if ($current) {
$query->where(['id >' => $current]);
}
$query->limit($limit);
return $query;
}
示例2: getUser
public function getUser(Request $request)
{
try {
$this->Server->isValidRequest(true, $request->query('access_token'));
$ownerModel = $this->Server->getAccessToken()->getSession()->getOwnerType();
$ownerId = $this->Server->getAccessToken()->getSession()->getOwnerId();
$event = new Event('OAuthServer.getUser', $request, [$ownerModel, $ownerId]);
EventManager::instance()->dispatch($event);
if ($event->result) {
return $event->result;
} else {
$model = TableRegistry::get($ownerModel);
return $model->get($ownerId)->toArray();
}
} catch (OAuthException $e) {
$this->_exception = $e;
return false;
}
}
示例3: testQueryWithArray
/**
* Test the query() method with arrays passed via $_GET
*
* @return void
*/
public function testQueryWithArray()
{
$get['test'] = ['foo', 'bar'];
$request = new Request(['query' => $get]);
$result = $request->query('test');
$this->assertEquals(['foo', 'bar'], $result);
$result = $request->query('test.1');
$this->assertEquals('bar', $result);
$result = $request->query('test.2');
$this->assertNull($result);
}
示例4: _getToken
/**
* Get token from header or query string.
*
* @param \Cake\Network\Request $request Request object.
* @return string|bool Token string if found else false.
*/
protected function _getToken($request)
{
$token = $request->env('HTTP_AUTHORIZATION');
// @codeCoverageIgnoreStart
if (!$token && function_exists('getallheaders')) {
$headers = getallheaders();
if (isset($headers['Authorization']) && substr($headers['Authorization'], 0, 7) === 'Bearer ') {
$token = $headers['Authorization'];
}
}
// @codeCoverageIgnoreEnd
if ($token) {
return substr($token, 7);
}
if (!empty($this->_config['parameter']) && isset($request->query[$this->_config['parameter']])) {
$token = $request->query($this->_config['parameter']);
}
return $token ? $token : false;
}
示例5: querystring
/**
* Get the api key from the querystring
*
* @param Request $request request
* @return string api key
*/
public function querystring(Request $request)
{
$name = $this->config('name');
return $request->query($name);
}
示例6: getToken
/**
* Get token from header or query string.
*
* @param \Cake\Network\Request|null $request Request object.
* @return string|null Token string if found else null.
*/
public function getToken($request = null)
{
$config = $this->_config;
if (!$request) {
return $this->_token;
}
$header = $request->header($config['header']);
if ($header) {
return $this->_token = str_ireplace($config['prefix'] . ' ', '', $header);
}
if (!empty($this->_config['parameter'])) {
$token = $request->query($this->_config['parameter']);
}
return $this->_token = $token;
}
示例7: _getToken
/**
* Get token from header or query string.
*
* @param \Cake\Network\Request $request Request object.
* @return string|bool Token string if found else false.
*/
protected function _getToken($request)
{
$token = $request->env('HTTP_AUTHORIZATION');
// @codeCoverageIgnoreStart
if (!$token && function_exists('getallheaders')) {
// index of the array returned by the function getallheaders() is case-insensitive.
// @see http://php.net/manual/en/function.getallheaders.php#52029
$headers = array_change_key_case(getallheaders());
if (isset($headers['authorization']) && substr($headers['authorization'], 0, 7) === 'Bearer ') {
$token = $headers['authorization'];
}
}
// @codeCoverageIgnoreEnd
if ($token) {
return substr($token, 7);
}
if (!empty($this->_config['parameter']) && isset($request->query[$this->_config['parameter']])) {
$token = $request->query($this->_config['parameter']);
}
return $token ? $token : false;
}
示例8: getPrev
/**
* Get the prev cursor value.
*
* @return mixed
*/
public function getPrev()
{
return $this->request->query('previous');
}
示例9: getToken
/**
* Get token from header or query string.
*
* @param \Cake\Network\Request|null $request Request object.
*
* @return string|null Token string if found else null.
*/
public function getToken($request = null)
{
$config = $this->_config;
if (!$request) {
return $this->_token;
}
// $header = $request->header($config['header']);
$header = isset(getallheaders()['Authorization']) ? getallheaders()['Authorization'] : null;
if ($header) {
return $this->_token = str_ireplace($config['prefix'] . ' ', '', $header);
}
if (!empty($this->_config['parameter'])) {
$token = $request->query($this->_config['parameter']);
}
return $this->_token = $token;
}