本文整理汇总了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();
}
示例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)];
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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();
}
示例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']);
}