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


PHP Request::getRequestUri方法代码示例

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


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

示例1: getRequestUri

 /**
  * @return string
  */
 public function getRequestUri()
 {
     if (null === $this->request) {
         throw new \LogicException('No Request set for RequestUriProviderByListener. Do not use this service manually.');
     }
     return $this->request->getRequestUri();
 }
开发者ID:sstok,项目名称:rollerworks-datagrid-bundle,代码行数:10,代码来源:RequestUriProviderByListener.php

示例2: doEnhance

 /**
  * {@inheritdoc}
  */
 protected function doEnhance(CustomUrlBehavior $customUrl, Webspace $webspace, array $defaults, Request $request)
 {
     if ($request->getRequestUri() === '/' || substr($request->getRequestUri(), -1, 1) !== '/') {
         return [];
     }
     return ['_finalized' => true, '_controller' => 'SuluWebsiteBundle:Default:redirect', 'url' => substr($request->getUri(), 0, -1)];
 }
开发者ID:sulu,项目名称:sulu,代码行数:10,代码来源:TrailingSlashEnhancer.php

示例3: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if (strpos($request->getRequestUri(), 'installer') !== false || !$this->isInstalled()) {
         define('MAUTIC_INSTALLER', 1);
     }
     if (defined('MAUTIC_INSTALLER')) {
         $uri = $request->getRequestUri();
         if (strpos($uri, 'installer') === false) {
             $base = $request->getBaseUrl();
             //check to see if the .htaccess file exists or if not running under apache
             if (strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') === false || !file_exists(__DIR__ . '../.htaccess') && strpos($base, 'index') === false) {
                 $base .= '/index.php';
             }
             return new RedirectResponse($base . '/installer');
         }
     }
     if (false === $this->booted) {
         $this->boot();
     }
     // Check for an an active db connection and die with error if unable to connect
     if (!defined('MAUTIC_INSTALLER')) {
         $db = $this->getContainer()->get('database_connection');
         try {
             $db->connect();
         } catch (\Exception $e) {
             error_log($e);
             throw new \Mautic\CoreBundle\Exception\DatabaseConnectionException($this->getContainer()->get('translator')->trans('mautic.core.db.connection.error', ['%code%' => $e->getCode()]));
         }
     }
     return parent::handle($request, $type, $catch);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:34,代码来源:AppKernel.php

示例4: match

 /**
  *
  * @param Request $request
  * @throws AppException
  * @return ApplicationUri
  */
 public function match($request)
 {
     $found = null;
     $uris = ApplicationUriQuery::create()->joinApplication()->filterByHttphost($request->getHttpHost())->find();
     $requestUri = Text::create($request->getRequestUri())->trimRight('/');
     foreach ($uris as $uri) {
         $basepath = new Text($uri->getBasepath());
         // either request uri and uri basepath are both empty
         // or request uri starts with basepath
         if ($basepath->isEmpty() && $uri->getHttphost() == $request->getHttpHost() || $requestUri->startsWith($basepath)) {
             // assign when it's the first found
             if ($found === null) {
                 $found = $uri;
             } else {
                 if ($basepath->count('/') > Text::create($found->getBasepath())->count('/')) {
                     $found = $uri;
                 }
             }
         }
     }
     if ($found === null) {
         throw new AppException(sprintf('No app found on %s', $request->getUri()), 404);
     }
     $this->destination = str_replace($found->getBasepath(), '', $request->getRequestUri());
     return $found;
 }
开发者ID:keeko,项目名称:framework,代码行数:32,代码来源:ApplicationRouter.php

示例5: 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

示例6: matchItem

 public function matchItem(ItemInterface $item)
 {
     if (null === $this->request || null === $item->getUri()) {
         return null;
     }
     if ($item->getUri() === $this->request->getRequestUri()) {
         return true;
     }
     return null;
 }
开发者ID:chazer,项目名称:KnpIpsum,代码行数:10,代码来源:Voter.php

示例7: isWordpressAdminPage

 protected function isWordpressAdminPage(Request $request)
 {
     if (preg_match('/wp-admin/', $request->getRequestUri())) {
         return true;
     }
     if (preg_match('/admin/', $request->getRequestUri())) {
         return true;
     }
     return false;
 }
开发者ID:mindgruve,项目名称:mg-reverse-proxy,代码行数:10,代码来源:WordPressAdapter.php

示例8: matchesPath

 public function matchesPath()
 {
     $urlFrom = $this->map->getUrlFrom();
     $requestUri = $this->request->getRequestUri();
     if (!$this->map->getUrlFromIsRegexPattern()) {
         $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
         return $this->map->getUrlFromIsNoCase() ? $strtolower($urlFrom) === $strtolower($requestUri) : $urlFrom === $requestUri;
     }
     $regexModifier = $this->map->getUrlFromIsNoCase() ? 'i' : '';
     return preg_match('#' . $urlFrom . '#' . $regexModifier, $requestUri, $this->patternMatches);
 }
开发者ID:byteworks-ch,项目名称:AstinaRedirectManagerBundle,代码行数:11,代码来源:Redirect.php

示例9: __invoke

 public function __invoke(Application $app, Request $request, $id)
 {
     $requestJson = $request->getContent() ?: "{}";
     $data = json_decode($requestJson);
     $this->validate($app, $id, $data);
     $isCreated = !$this->service->contains($request->getRequestUri());
     if ($this->service->save($request->getRequestUri(), $data) === false) {
         throw new ServiceUnavailableHttpException(null, "Failed to save resource");
     }
     return JsonResponse::create($data, $isCreated ? Response::HTTP_CREATED : Response::HTTP_OK);
 }
开发者ID:jdesrosiers,项目名称:resourceful,代码行数:11,代码来源:PutResourceController.php

示例10: getTranslatableDomain

 /**
  * Returns the domain to use according to the current request.
  * If there is no valid request, null will be returned..
  *
  * @return string domain
  */
 public function getTranslatableDomain()
 {
     $ret = null;
     if ($this->request instanceof Request) {
         $uriParts = explode('/', substr($this->request->getRequestUri(), 1));
         if (isset($uriParts[0])) {
             $ret = $uriParts[0];
         }
     }
     return $ret;
 }
开发者ID:smoskalenko,项目名称:graviton,代码行数:17,代码来源:I18nUtils.php

示例11: __invoke

 public function __invoke(Request $request)
 {
     if (!$this->service->contains($request->getRequestUri())) {
         throw new NotFoundHttpException("Not Found");
     }
     $resource = $this->service->fetch($request->getRequestUri());
     if ($resource === false) {
         throw new ServiceUnavailableHttpException(null, "Failed to retrieve resource");
     }
     $response = JsonResponse::create($resource);
     $response->headers->set("Content-Type", $this->contentType);
     return $response;
 }
开发者ID:jdesrosiers,项目名称:resourceful,代码行数:13,代码来源:GetResourceController.php

示例12: handle

 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if ($request->getRequestUri() == "/") {
         return new Response("public");
     }
     if ($request->getRequestUri() == "/protected") {
         return new Response("protected");
     }
     if ($request->getRequestUri() == "/anon") {
         return new Response("anonymous");
     }
     return new Response("invalid");
 }
开发者ID:rossriley,项目名称:stack-basic-authentication,代码行数:13,代码来源:TestApp.php

示例13: matchItem

 /**
  * @param ItemInterface $item
  *
  * @return bool
  */
 public function matchItem(ItemInterface $item)
 {
     $requestUri = $this->request->getRequestUri();
     $baseUrl = $this->request->getBaseUrl() . '/';
     $uri = $item->getUri();
     if ($uri === $requestUri) {
         return true;
     } else {
         if ($uri !== $baseUrl && substr($requestUri, 0, strlen($uri)) === $uri) {
             return true;
         }
     }
     return null;
 }
开发者ID:RamosBruno,项目名称:facebookQuizz,代码行数:19,代码来源:RequestVoter.php

示例14: __construct

 /**
  * Request constructor.
  *
  * @param        $request
  * @param        $response
  * @param string $username
  */
 public function __construct(SymfonyRequest $request, Response $response, $username = 'anonymous')
 {
     $this->request = $request;
     $this->response = $response;
     $this->username = $username;
     $this->uri = $request->getRequestUri();
 }
开发者ID:elcweb,项目名称:requestlogger-bundle,代码行数:14,代码来源:Request.php

示例15: localeRedirectAction

 /**
  * This route decides wheater a request has a missing locale or it is a missing page
  *
  * @param Request $request
  *
  * @return Response
  */
 public function localeRedirectAction(Request $request)
 {
     $requestUri = $request->getRequestUri();
     $explodedUri = explode('/', $requestUri);
     $doubleSlash = substr($requestUri, 0, 2) === '//';
     if (!$doubleSlash) {
         // does not start with 2 slashes
         if (strlen($explodedUri[1]) !== 2) {
             // no locale supplied
             $matchingRoute = $this->get('router')->match("/" . $requestUri);
         } else {
             // 404
             throw $this->createNotFoundException();
         }
     } else {
         $requestUri = substr($requestUri, 2);
         // Removed first 2 slashes
         $locale = empty($request->getLocale()) ? $request->getDefaultLocale() : mb_substr($request->getLocale(), 0, 2);
         $requestUri = '/' . $locale . '/' . $requestUri;
         $matchingRoute = $this->get('router')->match($requestUri);
     }
     if ($matchingRoute['_controller'] === 'Ashura\\OptionalLocaleBundle\\Controller\\DefaultController::localeRedirectAction') {
         throw $this->createNotFoundException();
     }
     return $this->forward($matchingRoute['_controller']);
 }
开发者ID:CoalaJoe,项目名称:OptionalLocaleBundle,代码行数:33,代码来源:DefaultController.php


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