Commit 3ac9d4cc authored by alexpott's avatar alexpott

Issue #2401395 by dawehner: <none> does not work as expected with fragments

parent 041511a7
......@@ -858,10 +858,6 @@ services:
- { name: path_processor_inbound, priority: 200 }
- { name: path_processor_outbound, priority: 200 }
arguments: ['@config.factory']
route_processor_none:
class: Drupal\Core\RouteProcessor\RouteProcessorNone
tags:
- { name: route_processor_outbound, priority: 200 }
route_processor_current:
class: Drupal\Core\RouteProcessor\RouteProcessorCurrent
arguments: ['@current_route_match']
......
<?php
/**
* @file
* Contains \Drupal\Core\RouteProcessor\RouteProcessorNone.
*/
namespace Drupal\Core\RouteProcessor;
use Symfony\Component\Routing\Route;
/**
* Provides a route processor to replace <none>.
*/
class RouteProcessorNone implements OutboundRouteProcessorInterface {
/**
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters) {
if ($route_name === '<none>') {
$route->setPath('');
}
}
}
......@@ -192,6 +192,11 @@ public function generateFromRoute($name, $parameters = array(), $options = array
$absolute = !empty($options['absolute']);
if (!$absolute || !$host = $this->context->getHost()) {
if ($route->getOption('_only_fragment')) {
return $fragment;
}
return $base_url . $path . $fragment;
}
......
......@@ -49,7 +49,7 @@ function locale_test_locale_translation_projects_alter(&$projects) {
// Instead of the default ftp.drupal.org we use the file system of the test
// instance to simulate a remote file location.
$url = \Drupal::url('<none>', [], ['absolute' => TRUE]);
$url = \Drupal::url('<front>', [], ['absolute' => TRUE]);
$remote_url = $url . PublicStream::basePath() . '/remote/';
// Completely replace the project data with a set of test projects.
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\system\Tests\PathProcessor\RouteProcessorNoneIntegrationTest.
* Contains \Drupal\system\Tests\PathProcessor\RouteNoneTest.
*/
namespace Drupal\system\Tests\RouteProcessor;
......@@ -13,10 +13,11 @@
use Symfony\Component\Routing\Route;
/**
* @see \Drupal\Core\RouteProcessor\RouteProcessorNone
* @see system.routing.yml
* @see \Drupal\Core\Routing\UrlGenerator
* @group route_processor
*/
class RouteProcessorNoneIntegrationTest extends KernelTestBase {
class RouteNoneTest extends KernelTestBase {
/**
* {@inheritdoc}
......@@ -53,8 +54,8 @@ public function testProcessOutbound() {
$request_stack->push($request);
$request_context->fromRequest($request);
$this->assertEqual('/subdir/', \Drupal::url('<none>'));
$this->assertEqual('/subdir/#test-fragment', \Drupal::url('<none>', [], ['fragment' => 'test-fragment']));
$this->assertEqual('', \Drupal::url('<none>'));
$this->assertEqual('#test-fragment', \Drupal::url('<none>', [], ['fragment' => 'test-fragment']));
// Test request with subdir on other page.
$server = [
......@@ -68,8 +69,8 @@ public function testProcessOutbound() {
$request_stack->push($request);
$request_context->fromRequest($request);
$this->assertEqual('/subdir/', \Drupal::url('<none>'));
$this->assertEqual('/subdir/#test-fragment', \Drupal::url('<none>', [], ['fragment' => 'test-fragment']));
$this->assertEqual('', \Drupal::url('<none>'));
$this->assertEqual('#test-fragment', \Drupal::url('<none>', [], ['fragment' => 'test-fragment']));
// Test request without subdir on the homepage.
$server = [
......@@ -83,8 +84,8 @@ public function testProcessOutbound() {
$request_stack->push($request);
$request_context->fromRequest($request);
$this->assertEqual('/', \Drupal::url('<none>'));
$this->assertEqual('/#test-fragment', \Drupal::url('<none>', [], ['fragment' => 'test-fragment']));
$this->assertEqual('', \Drupal::url('<none>'));
$this->assertEqual('#test-fragment', \Drupal::url('<none>', [], ['fragment' => 'test-fragment']));
// Test request without subdir on other page.
$server = [
......@@ -98,8 +99,8 @@ public function testProcessOutbound() {
$request_stack->push($request);
$request_context->fromRequest($request);
$this->assertEqual('/', \Drupal::url('<none>'));
$this->assertEqual('/#test-fragment', \Drupal::url('<none>', [], ['fragment' => 'test-fragment']));
$this->assertEqual('', \Drupal::url('<none>'));
$this->assertEqual('#test-fragment', \Drupal::url('<none>', [], ['fragment' => 'test-fragment']));
}
}
......@@ -379,7 +379,10 @@ system.theme_settings_theme:
_access: 'TRUE'
'<none>':
path: '<none>'
path: ''
options:
_only_fragment: TRUE
'<current>':
path: '<current>'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment