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


PHP ServerRequestInterface::getQueryParams方法代码示例

本文整理汇总了PHP中Psr\Http\Message\ServerRequestInterface::getQueryParams方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerRequestInterface::getQueryParams方法的具体用法?PHP ServerRequestInterface::getQueryParams怎么用?PHP ServerRequestInterface::getQueryParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Http\Message\ServerRequestInterface的用法示例。


在下文中一共展示了ServerRequestInterface::getQueryParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dispatch

 protected function dispatch(Request $request)
 {
     $method = $request->getMethod();
     if (!is_string($method)) {
         throw new ApiException(405, 'Unsupported HTTP method; must be a string, received ' . (is_object($method) ? get_class($method) : gettype($method)));
     }
     $method = strtoupper($method);
     /** @var Resource $resource */
     $resource = $this->getResource();
     if ('GET' === $method) {
         if ($id = $request->getAttribute(static::PK)) {
             $result = $resource->fetch($id, $request->getQueryParams());
         } else {
             $result = $resource->fetchAll($request->getQueryParams());
         }
     } elseif ('POST' === $method) {
         $result = $resource->create($request->getParsedBody());
     } elseif ('PUT' === $method) {
         $result = $resource->update($request->getAttribute(static::PK), $request->getParsedBody());
     } elseif ('PATCH' === $method) {
         $result = $resource->patch($request->getAttribute(static::PK), $request->getParsedBody());
     } elseif ('DELETE' === $method) {
         $result = $resource->delete($request->getAttribute(static::PK));
     } else {
         throw new ApiException(405, 'The ' . $method . ' method has not been defined');
     }
     return $result;
 }
开发者ID:maslennikov-yv,项目名称:rest,代码行数:28,代码来源:Action.php

示例2: __invoke

 public function __invoke(Request $request)
 {
     /** Check for token on header */
     if (isset($this->options['header'])) {
         if ($request->hasHeader($this->options['header'])) {
             $header = $request->getHeader($this->options['header'])[0];
             if (preg_match($this->options['regex'], $header, $matches)) {
                 return $matches[1];
             }
         }
     }
     /** If nothing on header, try query parameters */
     if (isset($this->options['parameter'])) {
         if (!empty($request->getQueryParams()[$this->options['parameter']])) {
             return $request->getQueryParams()[$this->options['parameter']];
         }
     }
     /** If nothing on parameters, try cookies */
     if (isset($this->options['cookie'])) {
         $cookie_params = $request->getCookieParams();
         if (!empty($cookie_params[$this->options["cookie"]])) {
             return $cookie_params[$this->options["cookie"]];
         }
     }
     /** If nothing until now, check argument as last try */
     if (isset($this->options['argument'])) {
         if ($route = $request->getAttribute('route')) {
             $argument = $route->getArgument($this->options['argument']);
             if (!empty($argument)) {
                 return $argument;
             }
         }
     }
     throw new TokenNotFoundException('Token not found');
 }
开发者ID:dyorg,项目名称:slim-token-authentication,代码行数:35,代码来源:TokenSearch.php

示例3: processRequest

 /**
  * Renders/Echoes the ajax output
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface|NULL
  * @throws \InvalidArgumentException
  */
 public function processRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     $action = isset($request->getParsedBody()['action']) ? $request->getParsedBody()['action'] : (isset($request->getQueryParams()['action']) ? $request->getQueryParams()['action'] : '');
     if (!in_array($action, array('route', 'getAPI'), true)) {
         return null;
     }
     $this->routeAction($action);
     return $this->ajaxObject->render();
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:17,代码来源:ExtDirectEidController.php

示例4: toZend

 /**
  * Convert a PSR-7 ServerRequest to a Zend\Http server-side request.
  *
  * @param ServerRequestInterface $psr7Request
  * @param bool $shallow Whether or not to convert without body/file
  *     parameters; defaults to false, meaning a fully populated request
  *     is returned.
  * @return Zend\Request
  */
 public static function toZend(ServerRequestInterface $psr7Request, $shallow = false)
 {
     if ($shallow) {
         return new Zend\Request($psr7Request->getMethod(), $psr7Request->getUri(), $psr7Request->getHeaders(), $psr7Request->getCookieParams(), $psr7Request->getQueryParams(), [], [], $psr7Request->getServerParams());
     }
     $zendRequest = new Zend\Request($psr7Request->getMethod(), $psr7Request->getUri(), $psr7Request->getHeaders(), $psr7Request->getCookieParams(), $psr7Request->getQueryParams(), $psr7Request->getParsedBody() ?: [], self::convertUploadedFiles($psr7Request->getUploadedFiles()), $psr7Request->getServerParams());
     $zendRequest->setContent($psr7Request->getBody());
     return $zendRequest;
 }
开发者ID:MidnightDesign,项目名称:zend-psr7bridge,代码行数:18,代码来源:Psr7ServerRequest.php

示例5: __invoke

 public function __invoke(Request $req, Response $res, callable $next) : Response
 {
     if (isset($req->getQueryParams()['redirect'])) {
         $redirect = $this->session->getSegment('redirect');
         $redirect->set('auth', $req->getQueryParams()['redirect']);
     }
     $auth = new Opauth($this->config);
     return $res;
 }
开发者ID:vrkansagara,项目名称:mwop.net,代码行数:9,代码来源:Auth.php

示例6: getData

 /**
  * {@inheritdoc}
  */
 public function getData()
 {
     $headers = [];
     foreach ($this->request->getHeaders() as $name => $values) {
         $headers[$name] = implode(', ', $values);
     }
     $data = ['SERVER' => $this->request->getServerParams(), 'QUERY' => $this->request->getQueryParams(), 'COOKIES' => $this->request->getCookieParams(), 'HEADERS' => $headers, 'ATTRIBUTES' => $this->request->getAttributes()];
     return $data;
 }
开发者ID:weierophinney,项目名称:prophiler-psr7-middleware,代码行数:12,代码来源:Request.php

示例7: processAjaxRequest

 /**
  * Processes all AJAX calls and returns a JSON for the data
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function processAjaxRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     // do the regular / main logic, depending on the action parameter
     $action = isset($request->getParsedBody()['action']) ? $request->getParsedBody()['action'] : $request->getQueryParams()['action'];
     $key = isset($request->getParsedBody()['key']) ? $request->getParsedBody()['fileName'] : $request->getQueryParams()['key'];
     $value = isset($request->getParsedBody()['value']) ? $request->getParsedBody()['value'] : $request->getQueryParams()['value'];
     $content = $this->process($action, $key, $value);
     $response->getBody()->write(json_encode($content));
     return $response;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:17,代码来源:UserSettingsController.php

示例8: __invoke

 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable|null $next
  * @return HtmlResponse
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     $templateName = $this->defaultTemplateName;
     $layoutName = $this->defaultLayoutName;
     if (isset($request->getQueryParams()['t'])) {
         $templateName = $request->getQueryParams()['t'];
     }
     if (isset($request->getQueryParams()['l'])) {
         $layoutName = $request->getQueryParams()['l'];
     }
     return new HtmlResponse($this->template->render('proto::' . $templateName, ['layout' => 'proto-layout::' . $layoutName]));
 }
开发者ID:t4web,项目名称:ZE-Prototype,代码行数:18,代码来源:ViewAction.php

示例9: isValidRequest

 /**
  * Checks if the request token is valid. This is checked to see if the route is really
  * created by the same instance. Should be called for all routes in the backend except
  * for the ones that don't require a login.
  *
  * @param \Psr\Http\Message\ServerRequestInterface $request
  * @return bool
  * @see \TYPO3\CMS\Backend\Routing\UriBuilder where the token is generated.
  */
 protected function isValidRequest($request)
 {
     $route = $request->getAttribute('route');
     if ($route->getOption('access') === 'public') {
         return true;
     } elseif ($route->getOption('ajax')) {
         $token = (string) (isset($request->getParsedBody()['ajaxToken']) ? $request->getParsedBody()['ajaxToken'] : $request->getQueryParams()['ajaxToken']);
         return $this->getFormProtection()->validateToken($token, 'ajaxCall', $route->getOption('_identifier'));
     } else {
         $token = (string) (isset($request->getParsedBody()['token']) ? $request->getParsedBody()['token'] : $request->getQueryParams()['token']);
         return $this->getFormProtection()->validateToken($token, 'route', $route->getOption('_identifier'));
     }
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:22,代码来源:RouteDispatcher.php

示例10: run

 /**
  * Set up the application and shut it down afterwards
  *
  * @param callable $execute
  * @return void
  */
 public function run(callable $execute = null)
 {
     $this->request = \TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals();
     // see below when this option is set and Bootstrap::defineTypo3RequestTypes() for more details
     if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
         $this->request = $this->request->withAttribute('isAjaxRequest', true);
     } elseif (isset($this->request->getQueryParams()['M'])) {
         $this->request = $this->request->withAttribute('isModuleRequest', true);
     }
     $this->bootstrap->handleRequest($this->request);
     if ($execute !== null) {
         call_user_func($execute);
     }
     $this->bootstrap->shutdown();
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:21,代码来源:Application.php

示例11: handleRequest

 /**
  * Handles an install tool request
  * Execute 'tool' or 'step' controller depending on install[controller] GET/POST parameter
  *
  * @param ServerRequestInterface $request
  * @return void
  */
 public function handleRequest(ServerRequestInterface $request)
 {
     $getPost = !empty($request->getQueryParams()['install']) ? $request->getQueryParams()['install'] : $request->getParsedBody()['install'];
     switch ($getPost['controller']) {
         case 'tool':
             $controllerClassName = \TYPO3\CMS\Install\Controller\ToolController::class;
             break;
         case 'ajax':
             $controllerClassName = \TYPO3\CMS\Install\Controller\AjaxController::class;
             break;
         default:
             $controllerClassName = \TYPO3\CMS\Install\Controller\StepController::class;
     }
     GeneralUtility::makeInstance($controllerClassName)->execute();
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:22,代码来源:RequestHandler.php

示例12: delete

 protected function delete(ServerRequestInterface $request)
 {
     $this->assertAdmin($request->getAttribute('actor'));
     $name = array_get($request->getQueryParams(), 'name');
     $this->extensions->disable($name);
     $this->extensions->uninstall($name);
 }
开发者ID:ygbhf,项目名称:flarum-full,代码行数:7,代码来源:UninstallExtensionController.php

示例13: data

 /**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $id = array_get($request->getQueryParams(), 'id');
     $actor = $request->getAttribute('actor');
     $file = array_get($request->getUploadedFiles(), 'avatar');
     return $this->bus->dispatch(new UploadAvatar($id, $file, $actor));
 }
开发者ID:clops,项目名称:core,代码行数:10,代码来源:UploadAvatarController.php

示例14: handle

 /**
  * @param Request $request
  * @return \Psr\Http\Message\ResponseInterface|RedirectResponse
  */
 public function handle(Request $request)
 {
     $redirectUri = (string) $request->getAttribute('originalUri', $request->getUri())->withQuery('');
     $server = new Twitter(['identifier' => $this->settings->get('flarum-auth-twitter.api_key'), 'secret' => $this->settings->get('flarum-auth-twitter.api_secret'), 'callback_uri' => $redirectUri]);
     $session = $request->getAttribute('session');
     $queryParams = $request->getQueryParams();
     $oAuthToken = array_get($queryParams, 'oauth_token');
     $oAuthVerifier = array_get($queryParams, 'oauth_verifier');
     if (!$oAuthToken || !$oAuthVerifier) {
         $temporaryCredentials = $server->getTemporaryCredentials();
         $session->set('temporary_credentials', serialize($temporaryCredentials));
         $session->save();
         // Second part of OAuth 1.0 authentication is to redirect the
         // resource owner to the login screen on the server.
         $server->authorize($temporaryCredentials);
         exit;
     }
     // Retrieve the temporary credentials we saved before
     $temporaryCredentials = unserialize($session->get('temporary_credentials'));
     // We will now retrieve token credentials from the server
     $tokenCredentials = $server->getTokenCredentials($temporaryCredentials, $oAuthToken, $oAuthVerifier);
     $user = $server->getUserDetails($tokenCredentials);
     $identification = ['twitter_id' => $user->uid];
     $suggestions = ['username' => $user->nickname, 'avatarUrl' => str_replace('_normal', '', $user->imageUrl)];
     return $this->authResponse->make($request, $identification, $suggestions);
 }
开发者ID:flarum,项目名称:auth-twitter,代码行数:30,代码来源:TwitterAuthController.php

示例15: delete

 /**
  * {@inheritdoc}
  */
 protected function delete(ServerRequestInterface $request)
 {
     $id = array_get($request->getQueryParams(), 'id');
     $actor = $request->getAttribute('actor');
     $input = $request->getParsedBody();
     $this->bus->dispatch(new DeleteDiscussion($id, $actor, $input));
 }
开发者ID:flarum,项目名称:core,代码行数:10,代码来源:DeleteDiscussionController.php


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