You are here

protected function RouterPathTranslatorSubscriber::cleanSubdirInPath in Decoupled Router 8

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/RouterPathTranslatorSubscriber.php \Drupal\decoupled_router\EventSubscriber\RouterPathTranslatorSubscriber::cleanSubdirInPath()

Removes the subdir prefix from the path.

Parameters

$path: The path that can contain the subdir prefix.

\Symfony\Component\HttpFoundation\Request $request: The request to extract the path prefix from.

Return value

string The clean path.

2 calls to RouterPathTranslatorSubscriber::cleanSubdirInPath()
RedirectPathTranslatorSubscriber::onPathTranslation in src/EventSubscriber/RedirectPathTranslatorSubscriber.php
Processes a path translation request.
RouterPathTranslatorSubscriber::onPathTranslation in src/EventSubscriber/RouterPathTranslatorSubscriber.php
Processes a path translation request.

File

src/EventSubscriber/RouterPathTranslatorSubscriber.php, line 365

Class

RouterPathTranslatorSubscriber
Event subscriber that processes a path translation with the router info.

Namespace

Drupal\decoupled_router\EventSubscriber

Code

protected function cleanSubdirInPath($path, Request $request) {

  // Remove any possible leading subdir information in case Drupal is
  // installed under http://example.com/d8/index.php
  $regexp = preg_quote($request
    ->getBasePath(), '/');
  return preg_replace(sprintf('/^%s/', $regexp), '', $path);
}