public function LanguageNegotiationUrl::processInbound in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl::processInbound()
Processes the inbound path.
Parameters
string $path: The path to process, with a leading slash.
\Symfony\Component\HttpFoundation\Request $request: The HttpRequest object representing the current request.
Return value
string The processed path.
Overrides InboundPathProcessorInterface::processInbound
File
- core/
modules/ language/ src/ Plugin/ LanguageNegotiation/ LanguageNegotiationUrl.php, line 106 - Contains \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl.
Class
- LanguageNegotiationUrl
- Class for identifying language via URL prefix or domain.
Namespace
Drupal\language\Plugin\LanguageNegotiationCode
public function processInbound($path, Request $request) {
$config = $this->config
->get('language.negotiation')
->get('url');
$parts = explode('/', trim($path, '/'));
$prefix = array_shift($parts);
// Search prefix within added languages.
foreach ($this->languageManager
->getLanguages() as $language) {
if (isset($config['prefixes'][$language
->getId()]) && $config['prefixes'][$language
->getId()] == $prefix) {
// Rebuild $path with the language removed.
$path = '/' . implode('/', $parts);
break;
}
}
return $path;
}