Helper function to handle multilingual paths.

Parameters

string $path_info: Path that might contain language prefix.

Return value

string Path without language prefix.

1 call to PathProcessor::getPath()
PathProcessor::processInbound in src/PathProcessor.php

File

src/PathProcessor.php, line 187

Class

PathProcessor
Processes the inbound path using path alias lookups.

Namespace

Drupal\subpathauto

Code

protected function getPath($path_info) {
    $prefixes = $this->getLanguageUrlPrefixes();
    $current_language_id = $this->languageManager
        ->getCurrentLanguage(LanguageInterface::TYPE_URL)
        ->getId();
    if (isset($prefixes[$current_language_id])) {
        $language_prefix = $prefixes[$current_language_id];
        $url_language_prefix = '/' . $language_prefix . '/';
        if (substr($path_info, 0, strlen($url_language_prefix)) == $url_language_prefix) {
            $path_info = '/' . substr($path_info, strlen($url_language_prefix));
        }
    }
    return rtrim(urldecode($path_info), '/');
}