Loading core/lib/Drupal/Core/Routing/UrlGenerator.php +13 −7 Original line number Diff line number Diff line Loading @@ -270,16 +270,15 @@ public function generateFromRoute($name, $parameters = [], $options = [], $colle $route = $this->getRoute($name); $generated_url = $collect_bubbleable_metadata ? new GeneratedUrl() : NULL; // Generate a relative URL having no path, just query string and fragment. if ($route->getOption('_no_path')) { $query = $options['query'] ? '?' . UrlHelper::buildQuery($options['query']) : ''; $fragment = ''; if (isset($options['fragment'])) { if (($fragment = trim($options['fragment'])) != '') { $fragment = '#' . $fragment; } } // Generate a relative URL having no path, just query string and fragment. if ($route->getOption('_no_path')) { $query = $options['query'] ? '?' . UrlHelper::buildQuery($options['query']) : ''; $url = $query . $fragment; return $collect_bubbleable_metadata ? $generated_url->setGeneratedUrl($url) : $url; } Loading Loading @@ -329,6 +328,13 @@ public function generateFromRoute($name, $parameters = [], $options = [], $colle $query = $options['query'] ? '?' . UrlHelper::buildQuery($options['query']) : ''; $fragment = ''; if (isset($options['fragment'])) { if (($fragment = trim($options['fragment'])) != '') { $fragment = '#' . $fragment; } } // The base_url might be rewritten from the language rewrite in domain mode. if (isset($options['base_url'])) { $base_url = $options['base_url']; Loading core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +3 −2 Original line number Diff line number Diff line Loading @@ -512,18 +512,19 @@ public function providerTestNoPath() { * Note: We use absolute covers to let * \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest work. */ public function testGenerateWithPathProcessorChangingQueryParameter() { public function testGenerateWithPathProcessorChangingOptions() { $path_processor = $this->createMock(OutboundPathProcessorInterface::CLASS); $path_processor->expects($this->atLeastOnce()) ->method('processOutbound') ->willReturnCallback(function ($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { $options['query'] = ['zoo' => 5]; $options['fragment'] = 'foo'; return $path; }); $this->processorManager->addOutbound($path_processor); $options = []; $this->assertGenerateFromRoute('test_2', ['narf' => 5], $options, '/goodbye/cruel/world?zoo=5', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); $this->assertGenerateFromRoute('test_2', ['narf' => 5], $options, '/goodbye/cruel/world?zoo=5#foo', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); } /** Loading Loading
core/lib/Drupal/Core/Routing/UrlGenerator.php +13 −7 Original line number Diff line number Diff line Loading @@ -270,16 +270,15 @@ public function generateFromRoute($name, $parameters = [], $options = [], $colle $route = $this->getRoute($name); $generated_url = $collect_bubbleable_metadata ? new GeneratedUrl() : NULL; // Generate a relative URL having no path, just query string and fragment. if ($route->getOption('_no_path')) { $query = $options['query'] ? '?' . UrlHelper::buildQuery($options['query']) : ''; $fragment = ''; if (isset($options['fragment'])) { if (($fragment = trim($options['fragment'])) != '') { $fragment = '#' . $fragment; } } // Generate a relative URL having no path, just query string and fragment. if ($route->getOption('_no_path')) { $query = $options['query'] ? '?' . UrlHelper::buildQuery($options['query']) : ''; $url = $query . $fragment; return $collect_bubbleable_metadata ? $generated_url->setGeneratedUrl($url) : $url; } Loading Loading @@ -329,6 +328,13 @@ public function generateFromRoute($name, $parameters = [], $options = [], $colle $query = $options['query'] ? '?' . UrlHelper::buildQuery($options['query']) : ''; $fragment = ''; if (isset($options['fragment'])) { if (($fragment = trim($options['fragment'])) != '') { $fragment = '#' . $fragment; } } // The base_url might be rewritten from the language rewrite in domain mode. if (isset($options['base_url'])) { $base_url = $options['base_url']; Loading
core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +3 −2 Original line number Diff line number Diff line Loading @@ -512,18 +512,19 @@ public function providerTestNoPath() { * Note: We use absolute covers to let * \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest work. */ public function testGenerateWithPathProcessorChangingQueryParameter() { public function testGenerateWithPathProcessorChangingOptions() { $path_processor = $this->createMock(OutboundPathProcessorInterface::CLASS); $path_processor->expects($this->atLeastOnce()) ->method('processOutbound') ->willReturnCallback(function ($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { $options['query'] = ['zoo' => 5]; $options['fragment'] = 'foo'; return $path; }); $this->processorManager->addOutbound($path_processor); $options = []; $this->assertGenerateFromRoute('test_2', ['narf' => 5], $options, '/goodbye/cruel/world?zoo=5', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); $this->assertGenerateFromRoute('test_2', ['narf' => 5], $options, '/goodbye/cruel/world?zoo=5#foo', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); } /** Loading