當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。