本文整理汇总了PHP中Zend\Http\Request::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getQuery方法的具体用法?PHP Request::getQuery怎么用?PHP Request::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\Request
的用法示例。
在下文中一共展示了Request::getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProcessGetRequest
public function testProcessGetRequest()
{
$moduleManager = $this->getMockBuilder('Zend\ModuleManager\ModuleManager')
->disableOriginalConstructor()
->getMock();
$moduleManager->expects($this->any())
->method('getLoadedModules')
->will($this->returnValue(array('ZFTest\Apigility\Admin\Model\TestAsset\Bar' => new BarModule)));
$moduleResource = new ModuleModel($moduleManager, array(), array());
$controller = new SourceController($moduleResource);
$request = new Request();
$request->setMethod('get');
$request->getQuery()->module = 'ZFTest\Apigility\Admin\Model\TestAsset\Bar';
$request->getQuery()->class = 'ZFTest\Apigility\Admin\Model\TestAsset\Bar\Module';
$controller->setRequest($request);
$result = $controller->sourceAction();
$this->assertTrue($result->getVariable('source') != '');
$this->assertTrue($result->getVariable('file') != '');
$this->assertEquals($result->getVariable('module'), $request->getQuery()->module);
$this->assertEquals($result->getVariable('class'), $request->getQuery()->class);
}
示例2: getIdentifier
/**
* @return string
*/
public function getIdentifier($paramName)
{
$tokenValue = $this->request->getQuery($paramName, false);
if ($tokenValue) {
return $tokenValue;
}
return md5(uniqid(rand(), true));
}
示例3: getIdentity
/** @return null|mixed */
protected function getIdentity()
{
$accessToken = $this->request->getQuery('access_token', $this->request->getPost('access_token'));
if ($accessToken === null) {
return null;
}
$oAuthRequest = OAuth2RequestFactory::create($this->request);
$accessTokenData = $this->oauthServer->getAccessTokenData($oAuthRequest);
return $this->identity = $this->identityStorageAdapter->findByUsername($accessTokenData['user_id']);
}
示例4: __invoke
/**
* Return logout text after user has logged out.
* Shown only after the first page load if loggedOut param is true.
*
* @return string Logout message
*/
public function __invoke()
{
if ($this->authManager->userHasLoggedOut() && $this->request->getQuery('logout', false)) {
if (!isset($this->session->logoutMessageShown) || !$this->session->logoutMessageShown) {
$this->session->logoutMessageShown = true;
return 'logout_success_message';
}
}
return false;
}
示例5: fromZend
/**
* Convert a Zend\Http\Response in a PSR-7 response, using zend-diactoros
*
* @param ZendRequest $zendRequest
* @return ServerRequest
*/
public static function fromZend(ZendRequest $zendRequest)
{
$body = new Stream('php://memory', 'wb+');
$body->write($zendRequest->getContent());
$headers = empty($zendRequest->getHeaders()) ? [] : $zendRequest->getHeaders()->toArray();
$query = empty($zendRequest->getQuery()) ? [] : $zendRequest->getQuery()->toArray();
$post = empty($zendRequest->getPost()) ? [] : $zendRequest->getPost()->toArray();
$files = empty($zendRequest->getFiles()) ? [] : $zendRequest->getFiles()->toArray();
$request = new ServerRequest([], self::convertFilesToUploaded($files), $zendRequest->getUriString(), $zendRequest->getMethod(), $body, $headers);
$request = $request->withQueryParams($query);
return $request->withParsedBody($post);
}
示例6: findRegion
public function findRegion($country, $query)
{
$request = new Request();
$request->setMethod(Request::METHOD_GET);
foreach ($query as $key => $value) {
$request->getQuery()->set($key, $value);
}
$request->getHeaders()->addHeaderLine('Accept', 'application/json');
switch ($country) {
case 'CH':
$request->setUri($this->config['url'] . '/ch-region');
break;
default:
$request->setUri($this->config['url'] . '/ch-region');
break;
}
$client = new Client();
$response = $client->send($request);
$body = $response->getBody();
$result = json_decode($body, true);
if ($result) {
return $result['_embedded']['ch_region'];
}
/*echo "<textarea cols='100' rows='30' style='position:relative; z-index:10000; width:inherit; height:200px;'>";
print_r($body);
echo "</textarea>";
die();*/
return null;
}
示例7: __construct
/**
* @param FacebookConfig $config
*/
public function __construct(array $config, Request $request)
{
$this->getParams = $request->getQuery()->toArray();
$error = $request->getQuery('error');
if (!empty($error)) {
$this->isValid = false;
return;
}
// if (!$config->isEnabled())
// {
// throw new \Exception('Twitter is not enabled');
// }
$this->consumerKey = $config['consumer_key'];
$this->consumerSecret = $config['consumer_secret'];
$this->returnUrlData = $config['return_url'];
}
示例8: login
/**
* Login
*
* @param \Zend\Http\Request $request
* @param \Zend\Http\Response $response
* @return null|array|\Zend\Http\Response
*/
public function login(array $options, HttpRequest $request, HttpResponse $response = null)
{
if (null === $response) {
$response = new PhpResponse();
}
$session = $this->getSessionContainer();
$code = $request->getQuery('code');
if (empty($options['redirect_uri'])) {
$options['redirect_uri'] = $request->getUri()->getScheme() . '://' . $this->getSiteInfo()->getFulldomain() . $request->getRequestUri();
}
if (empty($code)) {
$session['state'] = String::generateRandom(32);
$session['redirect_uri'] = $options['redirect_uri'];
$response->setContent('')->setStatusCode(302)->getHeaders()->clearHeaders()->addHeaderLine('Location', static::DIALOG_URI . '?' . http_build_query(array('client_id' => $options['client_id'], 'redirect_uri' => $options['redirect_uri'], 'state' => $session['state'], 'scope' => 'email')));
if ($response instanceof PhpResponse) {
$response->send();
exit;
} else {
return $response;
}
}
$state = $request->getQuery('state');
if (empty($session['state']) || $state !== $session['state']) {
return null;
}
$client = $this->getHttpClient();
$params = null;
@parse_str($client->setMethod('GET')->setUri(static::ACCESS_URI)->setParameterGet(array('client_id' => $options['client_id'], 'redirect_uri' => $session['redirect_uri'], 'client_secret' => $options['client_secret'], 'code' => $code))->send()->getBody(), $params);
unset($session['state']);
unset($session['redirect_uri']);
if (empty($params['access_token'])) {
return null;
}
return @json_decode($client->setMethod('GET')->setUri(static::API_URI)->setParameterGet(array('access_token' => $params['access_token']))->send()->getBody(), true);
}
示例9: makeRequestByOperation
/**
* Prepare a Zend Request by Operation with $parameters
*
* @param Operation $operation
* @param array $parameters
* @param int $options BitMask of options to skip or something else
* @return Request
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function makeRequestByOperation(Operation $operation, array $parameters = [], $options = 0)
{
$request = new Request();
$path = $operation->path;
if ($operation->parameters) {
foreach ($operation->parameters as $parameter) {
if (isset($parameters[$parameter->name])) {
switch ($parameter->in) {
case 'path':
$path = str_replace('{' . $parameter->name . '}', $parameters[$parameter->name], $path);
break;
case 'query':
$request->getQuery()->set($parameter->name, $parameters[$parameter->name]);
break;
case 'formData':
$request->getPost()->set($parameter->name, $parameters[$parameter->name]);
break;
default:
throw new RuntimeException(sprintf('Parameter "%s" with ->in = "%s" is not supported', $parameter->parameter, $parameter->in));
}
} elseif ($parameter->required && !($options & SwaggerWrapper::SKIP_REQUIRED)) {
throw new InvalidArgumentException(sprintf('Parameter "%s" is required, please pass value for this in $parameters', $parameter->name));
}
}
}
$request->setUri($path);
$request->setMethod($operation->method);
return $request;
}
示例10: testToUriStringMultiQueryOverwrite
public function testToUriStringMultiQueryOverwrite()
{
$request = new Request();
$request->setUri('http://google.ca/test.html?foo=bar');
$request->getQuery()->set('foo', 'value');
$this->assertEquals('http://google.ca/test.html?foo=value', RequestUtils::toUriString($request));
}
示例11: __invoke
public function __invoke($name = null, $params = [], $options = [], $reuseMatchedParams = false)
{
if (null === $this->router) {
throw new Exception\RuntimeException('No RouteStackInterface instance provided');
}
if (3 === func_num_args() && is_bool($options)) {
$reuseMatchedParams = $options;
$options = [];
}
// Inherit query parameters
if ($reuseMatchedParams) {
$providedQueryParams = isset($options['query']) ? $options['query'] : [];
$currentQueryParams = $this->request->getQuery()->toArray();
$options['query'] = array_merge($currentQueryParams, $providedQueryParams);
}
return parent::__invoke($name, $params, $options, $reuseMatchedParams);
}
示例12: testQueryAccessTokenProxiesOAuthServer
public function testQueryAccessTokenProxiesOAuthServer()
{
$token = ['user_id' => 'test'];
$this->setupMockOAuth2Server($token);
$this->request->getQuery()->set('access_token', 'TOKEN');
$identity = $this->listener->__invoke($this->mvcAuthEvent);
$this->assertIdentityMatchesToken($token, $identity);
}
示例13: create
public static function create(HttpRequest $request)
{
$queryParams = $request->getQuery()->toArray();
$postParams = $request->getPost()->toArray();
$files = $request->getFiles()->toArray();
$cookies = ($c = $request->getCookie()) ? [$c] : [];
return new OAuth2Request($queryParams, $postParams, [], $cookies, $files, $_SERVER);
}
示例14: setUp
public function setUp()
{
$request = new Request();
$request->getQuery()->fromArray(array('all' => 'query', 'query_and_post' => 'query'));
$request->getPost()->fromArray(array('all' => 'post', 'query_and_post' => 'post', 'post_only' => 'post'));
$this->request = $request;
$this->routeMatch = new RouteMatch(array('all' => 'route'));
}
示例15: getHiddenFilters
/**
* Get an array of hidden filters
*
* @param string $searchClassId Active search class
* @param bool $returnDefaultsIfEmpty Whether to return default tab filters if
* no filters are currently active
* @param bool $ignoreCurrentRequest Whether to ignore hidden filters in
* the current request
*
* @return array
*/
public function getHiddenFilters($searchClassId, $returnDefaultsIfEmpty = true, $ignoreCurrentRequest = false)
{
$filters = $ignoreCurrentRequest ? null : $this->request->getQuery('hiddenFilters');
if (null === $filters && $returnDefaultsIfEmpty) {
$filters = $this->getDefaultTabHiddenFilters($searchClassId);
}
return null === $filters ? [] : $this->parseFilters($searchClassId, $filters);
}