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


PHP Request::getQueryString方法代码示例

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


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

示例1: generateUrlCanonical

 /**
  * @param CanonicalUrlEvent $event
  */
 public function generateUrlCanonical(CanonicalUrlEvent $event)
 {
     if ($event->getUrl() !== null) {
         return;
     }
     $parseUrlByCurrentLocale = $this->getParsedUrlByCurrentLocale();
     if (empty($parseUrlByCurrentLocale['host'])) {
         return;
     }
     // Be sure to use the proper domain name
     $canonicalUrl = $parseUrlByCurrentLocale['scheme'] . '://' . $parseUrlByCurrentLocale['host'];
     // preserving a potential subdirectory, e.g. http://somehost.com/mydir/index.php/...
     $canonicalUrl .= $this->request->getBaseUrl();
     // Remove script name from path, e.g. http://somehost.com/index.php/...
     $canonicalUrl = preg_replace("!/index(_dev)?\\.php!", '', $canonicalUrl);
     $path = $this->request->getPathInfo();
     if (!empty($path) && $path != "/") {
         $canonicalUrl .= $path;
         $canonicalUrl = rtrim($canonicalUrl, '/');
     } else {
         $queryString = $this->request->getQueryString();
         if (!empty($queryString)) {
             $canonicalUrl .= '/?' . $queryString;
         }
     }
     $event->setUrl($canonicalUrl);
 }
开发者ID:thelia-modules,项目名称:CanonicalUrl,代码行数:30,代码来源:CanonicalUrlListener.php

示例2: get

 function get(Request $req)
 {
     $resourceName = $req->get('resource');
     if (!isset($this->module["resourceEntityMappings"][$resourceName])) {
         throw new NotFoundHttpException();
     }
     $entityClass = $this->module["namespace"] . $this->module["resourceEntityMappings"][$resourceName];
     // Filterer entities queried?
     if ($req->getQueryString() != null) {
         $querystring = $req->getQueryString();
         $criteria = array();
         $queryParts = \explode('&', $querystring);
         foreach ($queryParts as $queryPart) {
             $key_value = \explode('=', $queryPart);
             $criteria[$key_value[0]] = urldecode($key_value[1]);
         }
         $entities = $this->em->getRepository($entityClass)->findBy($criteria);
         // Single entity queried?
     } elseif ($req->get('id') != null) {
         $id = $req->get('id');
         $entity = $this->em->getRepository($entityClass)->find($id);
         $entities = array($entity);
     } else {
         $entities = $this->em->getRepository($entityClass)->findAll();
     }
     return new Response($this->serializer->serialize(array($resourceName => $entities), 'json'), 200, array('Content-Type' => $req->getMimeType('json')));
 }
开发者ID:haus23,项目名称:haus23-api,代码行数:27,代码来源:QueryResourceController.php

示例3: switchAction

 /**
  * Action for locale switch
  *
  * @param Request $request
  *
  * @throws \InvalidArgumentException
  * @return RedirectResponse
  */
 public function switchAction(Request $request)
 {
     $_locale = $request->attributes->get('_locale', $request->getLocale());
     $statusCode = $request->attributes->get('statusCode', $this->statusCode);
     $useReferrer = $request->attributes->get('useReferrer', $this->useReferrer);
     $redirectToRoute = $request->attributes->get('route', $this->redirectToRoute);
     $metaValidator = $this->metaValidator;
     if (!$metaValidator->isAllowed($_locale)) {
         throw new \InvalidArgumentException(sprintf('Not allowed to switch to locale %s', $_locale));
     }
     // Redirect the User
     if ($useReferrer && $request->headers->has('referer')) {
         $response = new RedirectResponse($request->headers->get('referer'), $statusCode);
     } elseif ($this->router && $redirectToRoute) {
         $target = $this->router->generate($redirectToRoute, array('_locale' => $_locale));
         if ($request->getQueryString()) {
             if (!strpos($target, '?')) {
                 $target .= '?';
             }
             $target .= $request->getQueryString();
         }
         $response = new RedirectResponse($target, $statusCode);
     } else {
         // TODO: this seems broken, as it will not handle if the site runs in a subdir
         // TODO: also it doesn't handle the locale at all and can therefore lead to an infinite redirect
         $response = new RedirectResponse($request->getScheme() . '://' . $request->getHttpHost() . '/', $statusCode);
     }
     return $response;
 }
开发者ID:Sententiaregum,项目名称:LocaleBundle,代码行数:37,代码来源:LocaleController.php

示例4: serve

 /**
  * Handle and return response.
  *
  * @return Response
  *
  * @throws BadRequestException
  */
 public function serve()
 {
     Log::debug('Request received:', ['Method' => $this->request->getMethod(), 'URI' => $this->request->getRequestUri(), 'Query' => $this->request->getQueryString(), 'Protocal' => $this->request->server->get('SERVER_PROTOCOL'), 'Content' => $this->request->getContent()]);
     $result = $this->handleRequest();
     $response = $this->buildResponse($result['response']);
     Log::debug('Server response created:', compact('response'));
     return new Response($response);
 }
开发者ID:takatost,项目名称:wechat_open_platform,代码行数:15,代码来源:Server.php

示例5: getPathWithQueryString

 /**
  * @return string
  */
 private function getPathWithQueryString()
 {
     $path = $this->message->getPathInfo();
     $qs = $this->message->getQueryString();
     if ($qs === null) {
         return $path;
     } else {
         return "{$path}?{$qs}";
     }
 }
开发者ID:rubensayshi,项目名称:http-signatures-php,代码行数:13,代码来源:SigningString.php

示例6: getQueryString

 /**
  * @return string|null
  */
 public function getQueryString()
 {
     // Symfony\Component\HttpFoundation\Request::getQueryString() is not
     // suitable for HTTP signatures as it mangles the query string.
     if ($this->request->getQueryString() === null) {
         return;
     } else {
         return $this->request->server->get('QUERY_STRING');
     }
 }
开发者ID:rubensayshi,项目名称:http-signatures-php,代码行数:13,代码来源:SymfonyRequestMessage.php

示例7: writeLog

 public function writeLog(Request $request)
 {
     if ($this->getRequestCount() == 0) {
         return;
     }
     $message = sprintf('Executed %s API calls in %sms', $this->getRequestCount(), round($this->getTotalRequestTime() * 1000, 1));
     $context = array('requestCount' => $this->getRequestCount(), 'totalRequestTime' => $this->getTotalRequestTime(), 'method' => $request->getMethod(), 'path' => $request->getPathInfo());
     if ($request->getQueryString()) {
         $context['query'] = $request->getQueryString();
     }
     $this->logger->info($message, $context);
 }
开发者ID:aptoma,项目名称:silex-extras,代码行数:12,代码来源:RequestLoggerPlugin.php

示例8: indexAction

 /**
  * @param Request $request
  * @return JsonResponse
  */
 public function indexAction(Request $request, $formatName = "default")
 {
     $payload = file_get_contents('php://input');
     $content = "queryString: " . $request->getQueryString() . "\n payload: " . $payload;
     file_put_contents("/tmp/koalamon/webhook_" . $formatName . ".log", json_encode($content));
     $project = $this->getProject($request->get("api_key"));
     if ($project == null) {
         return $this->getJsonRespone(self::STATUS_FAILURE, "No project with api_key " . $request->get("api_key") . ' found.');
     }
     $rawEvent = $this->getFormatHandler()->run($formatName, $request, $payload);
     if ($rawEvent === false) {
         return $this->getJsonRespone(self::STATUS_SKIPPED);
     }
     $event = new Event();
     $event->setStatus($rawEvent->getStatus());
     $event->setMessage($rawEvent->getMessage());
     $event->setSystem($rawEvent->getSystem());
     $event->setType($rawEvent->getType());
     $event->setUnique($rawEvent->isUnique());
     $event->setUrl($rawEvent->getUrl());
     $event->setValue($rawEvent->getValue());
     $em = $this->getDoctrine()->getManager();
     $identifier = $em->getRepository('BauerIncidentDashboardCoreBundle:EventIdentifier')->findOneBy(array('project' => $project, 'identifier' => $rawEvent->getIdentifier()));
     if (is_null($identifier)) {
         $identifier = new EventIdentifier();
         $identifier->setProject($project);
         $identifier->setIdentifier($rawEvent->getIdentifier());
         $em->persist($identifier);
         $em->flush();
     }
     $event->setEventIdentifier($identifier);
     $translatedEvent = $this->translate($event);
     ProjectHelper::addEvent($this->get("Router"), $em, $translatedEvent);
     return $this->getJsonRespone(self::STATUS_SUCCESS);
 }
开发者ID:Bauer-Xcel-Media,项目名称:Koalamon,代码行数:39,代码来源:DefaultController.php

示例9: getRequestRelativeUri

 private function getRequestRelativeUri(Request $request)
 {
     if (null !== ($qs = $request->getQueryString())) {
         $qs = '?' . $qs;
     }
     return trim($request->getPathInfo(), '/') . $qs;
 }
开发者ID:makinacorpus,项目名称:drupal-minidialog,代码行数:7,代码来源:MiniDialogExtension.php

示例10: logExecTime

 public function logExecTime(Request $request)
 {
     $execTime = round(microtime(true) - $this['timer.start'], 6) * 1000;
     $message = sprintf('Script executed in %sms.', $execTime);
     $context = array('msExecTime' => $execTime, 'method' => $request->getMethod(), 'path' => $request->getPathInfo());
     if ($request->getQueryString()) {
         $context['query'] = $request->getQueryString();
     }
     if ($execTime < $this['timer.threshold_info']) {
         $this['logger']->debug($message, $context);
     } elseif ($execTime < $this['timer.threshold_warning']) {
         $this['logger']->info($message, $context);
     } else {
         $this['logger']->warn($message, $context);
     }
 }
开发者ID:aptoma,项目名称:silex-extras,代码行数:16,代码来源:Application.php

示例11: indexAction

 public function indexAction(Request $request)
 {
     try {
         $this->get('naoned.oaipmh.ruler')->checkParamsUnicity($request->getQueryString());
         $this->allArgs = $this->getAllArguments($request);
         if (!array_key_exists('verb', $this->allArgs)) {
             throw new BadVerbException('The verb argument is missing');
         }
         $verb = $this->allArgs['verb'];
         if (!in_array($verb, $this->availableVerbs)) {
             throw new BadVerbException('Value of the verb argument is not a legal OAI-PMH verb.');
         }
         $methodName = $verb . 'Verb';
         return $this->{$methodName}($request);
     } catch (\Exception $e) {
         if ($e instanceof OaiPmhServerException) {
             $reflect = new \ReflectionClass($e);
             //Remove «Exception» at end of class namespace
             $code = substr($reflect->getShortName(), 0, -9);
             // lowercase first char
             $code[0] = strtolower(substr($code, 0, 1));
         } elseif ($e instanceof NotFoundHttpException) {
             $code = 'notFoundError';
         } else {
             $code = 'unknownError';
         }
         return $this->error($code, $e->getMessage());
     }
 }
开发者ID:naoned,项目名称:OaiPmhServerBundle,代码行数:29,代码来源:MainController.php

示例12: parseRequest

 /**
  * Extracts filters from the Request
  */
 protected function parseRequest()
 {
     $this->parameters = [];
     $this->groups = [];
     $matchResult = preg_match_all('/(?P<key>((?P<group>[\\w\\d-\\.]+)(?P<path>(%5B[\\w\\d-\\.]+%5D)*)))' . '(?P<operator>(<|>|%3C|%3E)?=|<>|%3C%3E|(<|>|%3C|%3E))' . '(?P<value>[^&]+)/', $this->request->getQueryString(), $matches, PREG_SET_ORDER);
     if (false !== $matchResult) {
         foreach ($matches as $match) {
             $key = strtolower(rawurldecode($match['key']));
             $group = strtolower(rawurldecode($match['group']));
             $path = strtolower(rawurldecode($match['path']));
             $path = !empty($path) ? strtr($path, ['][' => ConfigUtil::PATH_DELIMITER, '[' => '', ']' => '']) : $key;
             $value = new FilterValue($path, rawurldecode($match['value']), rawurldecode(strtolower($match['operator'])));
             $this->parameters[$key] = $value;
             $this->groups[$group][$key] = $value;
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:20,代码来源:RestFilterValueAccessor.php

示例13: completeTrailingSlash

 /**
  * @param Request $request
  * @return string
  */
 public static function completeTrailingSlash(Request $request)
 {
     $queryString = $request->getQueryString();
     if ($queryString !== null) {
         $queryString = '?' . $queryString;
     }
     return $request->getBaseUrl() . $request->getPathInfo() . '/' . $queryString;
 }
开发者ID:xxoxx,项目名称:php-waf,代码行数:12,代码来源:RequestUtils.php

示例14: generateMetaTagKey

 public function generateMetaTagKey(Request $request, RouterInterface $router, $locale)
 {
     $pathInfo = $request->getPathInfo();
     $key = $this->generateMetaTagKeyFromRelativePath($pathInfo, $router, $locale);
     if ($this->addQueryString) {
         $key .= '?' . $request->getQueryString();
     }
     return $key;
 }
开发者ID:vstm,项目名称:IbrowsSimpleSeoBundle,代码行数:9,代码来源:KeyGenerator.php

示例15: create

 /**
  * {@inheritdoc}
  */
 public function create()
 {
     if (null === $this->request) {
         return null;
     }
     $http = new Http($this->request->getUriForPath($this->request->getPathInfo()), $this->request->getMethod());
     $queryString = $this->request->getQueryString();
     if (strlen($queryString) > 0) {
         $http->setQueryString($queryString);
     }
     $http->setData($this->request->request->all());
     $http->setCookies($this->request->cookies->all());
     $http->setHeaders(array_map(function (array $values) {
         return count($values) === 1 ? reset($values) : $values;
     }, $this->request->headers->all()));
     $http->setEnv($this->request->server->all());
     return $http;
 }
开发者ID:ruudk,项目名称:sentry-client,代码行数:21,代码来源:SymfonyHttpFactory.php


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