public function PathProcessorLanguage::processInbound

Implements Drupal\Core\PathProcessor\InboundPathProcessorInterface::processInbound().

Overrides InboundPathProcessorInterface::processInbound

File

drupal/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php, line 76
Contains Drupal\language\HttpKernel\PathProcessorLanguage.

Class

PathProcessorLanguage
Processes the inbound path using path alias lookups.

Namespace

Drupal\language\HttpKernel

Code

public function processInbound($path, Request $request) {
  if (!empty($path)) {
    $args = explode('/', $path);
    $prefix = array_shift($args);

    // Search prefix within enabled languages.
    $prefixes = $this->config
      ->get('language.negotiation')
      ->get('url.prefixes');
    foreach ($this->languages as $language) {
      if (isset($prefixes[$language->langcode]) && $prefixes[$language->langcode] == $prefix) {

        // Rebuild $path with the language removed.
        return implode('/', $args);
      }
    }
  }
  return $path;
}