Commit 3ac9d4cc authored by Alex Pott's avatar Alex Pott
Browse files

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

parent 041511a7
Loading
Loading
Loading
Loading
+0 −4
Changes for core/core.services.yml: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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']
+0 −26
Changes for core/lib/Drupal/Core/RouteProcessor/RouteProcessorNone.php: 0 added lines, 26 removed lines.
Original line number Diff line number Diff line
<?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('');
    }
  }

}
+5 −0
Changes for core/lib/Drupal/Core/Routing/UrlGenerator.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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;
    }

+1 −1
Changes for core/modules/locale/tests/modules/locale_test/locale_test.module: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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.
+12 −11
Changes for core/modules/system/src/Tests/RouteProcessor/RouteNoneTest.php: 12 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -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']));
  }

}
Loading