function AliasPathProcessor::processOutbound
Same name in other branches
- 9 core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php \Drupal\path_alias\PathProcessor\AliasPathProcessor::processOutbound()
- 10 core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php \Drupal\path_alias\PathProcessor\AliasPathProcessor::processOutbound()
Overrides OutboundPathProcessorInterface::processOutbound
File
-
core/
modules/ path_alias/ src/ PathProcessor/ AliasPathProcessor.php, line 44
Class
- AliasPathProcessor
- Processes the inbound path using path alias lookups.
Namespace
Drupal\path_alias\PathProcessorCode
public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) {
if (empty($options['alias'])) {
$langcode = isset($options['language']) ? $options['language']->getId() : NULL;
$path = $this->aliasManager
->getAliasByPath($path, $langcode);
// Ensure the resulting path has at most one leading slash, to prevent it
// becoming an external URL without a protocol like //example.com. This
// is done in \Drupal\Core\Routing\UrlGenerator::generateFromRoute()
// also, to protect against this problem in arbitrary path processors,
// but it is duplicated here to protect any other URL generation code
// that might call this method separately.
if (str_starts_with($path, '//')) {
$path = '/' . ltrim($path, '/');
}
}
return $path;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.