Same filename and directory in other branches
- 8.9.x core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php
- 9 core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php
Namespace
Drupal\path_alias\PathProcessor
File
core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php
View source
<?php
namespace Drupal\path_alias\PathProcessor;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\path_alias\AliasManagerInterface;
use Symfony\Component\HttpFoundation\Request;
class AliasPathProcessor implements InboundPathProcessorInterface, OutboundPathProcessorInterface {
protected $aliasManager;
public function __construct(AliasManagerInterface $alias_manager) {
$this->aliasManager = $alias_manager;
}
public function processInbound($path, Request $request) {
$path = $this->aliasManager
->getPathByAlias($path);
return $path;
}
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);
if (str_starts_with($path, '//')) {
$path = '/' . ltrim($path, '/');
}
}
return $path;
}
}
Classes