diff --git a/core/core.services.yml b/core/core.services.yml index 3c27130..5355141 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -491,7 +491,7 @@ services: - [setContext, ['@?router.request_context']] unrouted_url_assembler: class: Drupal\Core\Utility\UnroutedUrlAssembler - arguments: ['@request_stack', '@config.factory' ] + arguments: ['@path_processor_manager', '@request_stack', '@config.factory'] link_generator: class: Drupal\Core\Utility\LinkGenerator arguments: ['@url_generator', '@module_handler'] diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php index 08d0083..dd267d9 100644 --- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\PathProcessor\OutboundPathProcessorInterface; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -20,6 +21,13 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface { /** + * The path processor to convert the system path to one suitable for urls. + * + * @var \Drupal\Core\PathProcessor\OutboundPathProcessorInterface + */ + protected $pathProcessor; + + /** * A request stack object. * * @var \Symfony\Component\HttpFoundation\RequestStack @@ -29,14 +37,17 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface { /** * Constructs a new unroutedUrlAssembler object. * + * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor + * The path processor to convert the system path to one suitable for urls. * @param \Drupal\Core\Config\ConfigFactoryInterface $config * The config factory. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * A request stack object. */ - public function __construct(RequestStack $request_stack, ConfigFactoryInterface $config) { + public function __construct(OutboundPathProcessorInterface $path_processor, RequestStack $request_stack, ConfigFactoryInterface $config) { $allowed_protocols = $config->get('system.filter')->get('protocols') ?: ['http', 'https']; UrlHelper::setAllowedProtocols($allowed_protocols); + $this->pathProcessor = $path_processor; $this->requestStack = $request_stack; } @@ -99,6 +110,7 @@ protected function buildLocalUrl($uri, array $options = []) { // Remove the base:// scheme. $uri = substr($uri, 7); + $uri = $this->pathProcessor->processOutbound(trim($uri, '/'), $options, $this->requestStack->getCurrentRequest()); // Add any subdirectory where Drupal is installed. $current_base_path = $request->getBasePath() . '/'; diff --git a/core/modules/forum/src/Form/ForumForm.php b/core/modules/forum/src/Form/ForumForm.php index 6a8131a..fc51a32 100644 --- a/core/modules/forum/src/Form/ForumForm.php +++ b/core/modules/forum/src/Form/ForumForm.php @@ -107,10 +107,7 @@ protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); if (!$this->entity->isNew() && $this->entity->hasLinkTemplate('forum-delete-form')) { - $route_info = $this->entity->urlInfo('forum-delete-form'); - $actions['delete']['#options'] = $route_info->getOptions(); - $actions['delete']['#route_name'] = $route_info->getRouteName(); - $actions['delete']['#route_parameters'] = $route_info->getRouteParameters(); + $actions['delete']['#url'] = $this->entity->urlInfo('forum-delete-form'); } else { unset($actions['delete']); diff --git a/core/modules/views/src/Plugin/views/field/Links.php b/core/modules/views/src/Plugin/views/field/Links.php index a248bd6..3516346 100644 --- a/core/modules/views/src/Plugin/views/field/Links.php +++ b/core/modules/views/src/Plugin/views/field/Links.php @@ -8,7 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Url; +use Drupal\Core\Url as UrlObject; /** * A abstract handler which provides a collection of links. @@ -80,7 +80,7 @@ protected function getLinks() { $path = strip_tags(decode_entities(strtr($path, $tokens))); $links[$field] = array( - 'url' => Url::fromUri('base://' . $path), + 'url' => UrlObject::fromUri('base://' . $path), 'title' => $title, ); if (!empty($this->options['destination'])) { diff --git a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php index 03b3375..d24e1f0 100644 --- a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php @@ -47,7 +47,11 @@ protected function setUp() { $this->requestStack = new RequestStack(); $this->configFactory = $this->getConfigFactoryStub(['system.filter' => []]); - $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->configFactory); + $path_processor = $this->getMock('Drupal\Core\PathProcessor\OutboundPathProcessorInterface'); + $path_processor->expects($this->any()) + ->method('processOutbound') + ->willReturnArgument(0); + $this->unroutedUrlAssembler = new UnroutedUrlAssembler($path_processor, $this->requestStack, $this->configFactory); } /**