Commit 58480ee6 authored by alexpott's avatar alexpott

Issue #2362227 by dawehner, mpdonadio, znerol, tim.plunkett, skipyT: Replace...

Issue #2362227 by dawehner, mpdonadio, znerol, tim.plunkett, skipyT: Replace all instances of current_path()
parent 91b4829e
......@@ -566,7 +566,7 @@ services:
- { name: backend_overridable }
path.matcher:
class: Drupal\Core\Path\PathMatcher
arguments: ['@config.factory']
arguments: ['@config.factory', '@current_route_match']
path.validator:
class: Drupal\Core\Path\PathValidator
arguments: ['@router', '@router.no_access_checks', '@current_user', '@path_processor_manager']
......
......@@ -450,18 +450,20 @@ function _batch_finished() {
}
if ($_batch['form_state']->getRedirect() === NULL) {
$redirect = $_batch['batch_redirect'] ?: $_batch['source_url'];
$options = UrlHelper::parse($redirect);
// Any path with a scheme does not correspond to a route.
if (parse_url($options['path'], PHP_URL_SCHEME)) {
$redirect = Url::fromUri($options['path'], $options);
}
else {
$redirect = \Drupal::pathValidator()->getUrlIfValid($options['path']);
if (!$redirect) {
// Stay on the same page if the redirect was invalid.
$redirect = Url::fromRoute('<current>');
if (!$redirect instanceof Url) {
$options = UrlHelper::parse($redirect);
if (parse_url($options['path'], PHP_URL_SCHEME)) {
$redirect = Url::fromUri($options['path'], $options);
}
else {
$redirect = \Drupal::pathValidator()->getUrlIfValid($options['path']);
if (!$redirect) {
// Stay on the same page if the redirect was invalid.
$redirect = Url::fromRoute('<current>');
}
$redirect->setOptions($options);
}
$redirect->setOptions($options);
}
$_batch['form_state']->setRedirectUrl($redirect);
}
......@@ -480,16 +482,17 @@ function _batch_finished() {
$_SESSION['batch_form_state'] = $_batch['form_state'];
}
$callback = $_batch['redirect_callback'];
/** @var \Drupal\Core\Url $source_url */
$source_url = $_batch['source_url'];
if (is_callable($callback)) {
$callback($_batch['source_url'], array('query' => array('op' => 'finish', 'id' => $_batch['id'])));
}
elseif ($callback === NULL) {
// Default to RedirectResponse objects when nothing specified.
$url = _url($_batch['source_url'], array(
'absolute' => TRUE,
'query' => array('op' => 'finish', 'id' => $_batch['id']),
));
return new RedirectResponse($url);
$url = $source_url
->setAbsolute()
->setOption('query', ['op' => 'finish', 'id' => $_batch['id']]);
return new RedirectResponse($url->toString());
}
}
}
......
......@@ -1132,8 +1132,6 @@ function language_default() {
*
* @return
* The requested Drupal URL path.
*
* @see current_path()
*/
function request_path() {
static $path;
......@@ -1168,18 +1166,6 @@ function request_path() {
return $path;
}
/**
* @todo This is a temporary function pending refactoring Drupal to use
* Symfony's Request object exclusively.
*/
function _current_path($path = NULL) {
static $current_path = '';
if (isset($path)) {
$current_path = $path;
}
return $current_path;
}
/**
* Registers an additional namespace.
*
......
......@@ -23,6 +23,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\PhpStorage\PhpStorageFactory;
......@@ -245,7 +246,6 @@ function drupal_get_html_head($render = TRUE) {
* - destination: The path provided via the destination query string or, if
* not available, the current path.
*
* @see current_path()
* @ingroup form_api
*/
function drupal_get_destination() {
......@@ -260,7 +260,7 @@ function drupal_get_destination() {
$destination = array('destination' => $query->get('destination'));
}
else {
$path = current_path();
$path = \Drupal::routeMatch()->getRouteName() ? Url::fromRouteMatch(\Drupal::routeMatch())->getInternalPath() : '';
$query = UrlHelper::buildQuery(UrlHelper::filterQueryParameters($query->all()));
if ($query != '') {
$path .= '?' . $query;
......@@ -1469,18 +1469,20 @@ function _drupal_add_js($data = NULL, $options = NULL) {
// Instead of running the hook_url_outbound_alter() again here, extract
// them from url().
// @todo Make this less hacky: http://drupal.org/node/1547376.
$scriptPath = $GLOBALS['script_path'];
$request = \Drupal::request();
$scriptPath = $request->getScriptName();
$pathPrefix = '';
$current_query = \Drupal::service('request_stack')->getCurrentRequest()->query->all();
$current_query = $request->query->all();
_url('', array('script' => &$scriptPath, 'prefix' => &$pathPrefix));
$current_path = current_path();
$current_path = \Drupal::routeMatch()->getRouteName() ? Url::fromRouteMatch(\Drupal::routeMatch())->getInternalPath() : '';
$current_path_is_admin = FALSE;
// The function path_is_admin() is not available on update.php pages.
if (!(defined('MAINTENANCE_MODE'))) {
$current_path_is_admin = \Drupal::service('router.admin_context')->isAdminRoute();
}
$path = array(
'basePath' => base_path(),
'baseUrl' => $request->getBaseUrl() . '/',
'scriptPath' => $scriptPath,
'pathPrefix' => $pathPrefix,
'currentPath' => $current_path,
......
......@@ -15,6 +15,7 @@
use Drupal\Core\Form\OptGroup;
use Drupal\Core\Render\Element;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
......@@ -827,7 +828,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU
'progressive' => TRUE,
'url' => $url,
'url_options' => array(),
'source_url' => current_path(),
'source_url' => Url::fromRouteMatch(\Drupal::routeMatch()),
'batch_redirect' => $redirect,
'theme' => \Drupal::theme()->getActiveTheme()->getName(),
'redirect_callback' => $redirect_callback,
......
......@@ -39,36 +39,6 @@ function drupal_match_path($path, $patterns) {
return \Drupal::service('path.matcher')->matchPath($path, $patterns);
}
/**
* Return the current URL path of the page being viewed.
*
* Examples:
* - http://example.com/node/306 returns "node/306".
* - http://example.com/drupalfolder/node/306 returns "node/306" while
* base_path() returns "/drupalfolder/".
* - http://example.com/path/alias (which is a path alias for node/306) returns
* "node/306" as opposed to the path alias.
*
* @return string
* The current Drupal URL path.
*
* @see request_path()
*/
function current_path() {
// @todo Remove the check for whether the request service exists and the
// fallback code below, once the path alias logic has been figured out in
// http://drupal.org/node/1269742.
if ($request = \Drupal::request()) {
$path = $request->attributes->get('_system_path');
if ($path !== NULL) {
return $path;
}
}
// If we are outside the request scope, fall back to using the path stored in
// _current_path().
return _current_path();
}
/**
* Determines whether a path is in the administrative section of the site.
*
......
......@@ -22,6 +22,7 @@
use Drupal\Core\PageCache\RequestPolicyInterface;
use Drupal\Core\PhpStorage\PhpStorageFactory;
use Drupal\Core\Site\Settings;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
......@@ -32,6 +33,7 @@
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\TerminableInterface;
use Composer\Autoload\ClassLoader;
use Symfony\Component\Routing\Route;
/**
* The DrupalKernel class is the core of Drupal itself.
......@@ -585,6 +587,8 @@ public function prepareLegacyRequest(Request $request) {
$this->preHandle($request);
// Enter the request scope so that current_user service is available for
// locale/translation sake.
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>'));
$request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<none>');
$this->container->get('request_stack')->push($request);
$this->container->get('router.request_context')->fromRequest($request);
return $this;
......@@ -809,8 +813,6 @@ protected function initializeRequestGlobals(Request $request) {
global $base_secure_url, $base_insecure_url;
// @todo Refactor with the Symfony Request object.
_current_path(request_path());
if (isset($base_url)) {
// Parse fixed base URL from settings.php.
$parts = parse_url($base_url);
......
......@@ -8,6 +8,8 @@
namespace Drupal\Core\Path;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
/**
* Provides a path matcher.
......@@ -42,14 +44,24 @@ class PathMatcher implements PathMatcherInterface {
*/
protected $configFactory;
/**
* The current route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Creates a new PathMatcher.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
public function __construct(ConfigFactoryInterface $config_factory, RouteMatchInterface $route_match) {
$this->configFactory = $config_factory;
$this->routeMatch = $route_match;
}
/**
......@@ -84,7 +96,13 @@ public function matchPath($path, $patterns) {
public function isFrontPage() {
// Cache the result as this is called often.
if (!isset($this->isCurrentFrontPage)) {
$this->isCurrentFrontPage = (current_path() == $this->getFrontPagePath());
$this->isCurrentFrontPage = FALSE;
// Ensure that the code can also be executed when there is no active
// route match, like on exception responses.
if ($this->routeMatch->getRouteName()) {
$url = Url::fromRouteMatch($this->routeMatch);
$this->isCurrentFrontPage = ($url->getRouteName() && $url->getInternalPath() === $this->getFrontPagePath());
}
}
return $this->isCurrentFrontPage;
}
......@@ -98,6 +116,8 @@ public function isFrontPage() {
protected function getFrontPagePath() {
// Lazy-load front page config.
if (!isset($this->frontPage)) {
// @todo page.front should store the route name, see
// https://www.drupal.org/node/2371823
$this->frontPage = $this->configFactory->get('system.site')
->get('page.front');
}
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
/**
* Provides a base class for render element plugins.
......@@ -136,7 +137,7 @@ public static function processAjaxForm(&$element, FormStateInterface $form_state
/**
* Adds Ajax information about an element to communicate with JavaScript.
*
* If #ajax['path'] is set on an element, this additional JavaScript is added
* If #ajax['url'] is set on an element, this additional JavaScript is added
* to the page header to attach the Ajax behaviors. See ajax.js for more
* information.
*
......@@ -145,7 +146,7 @@ public static function processAjaxForm(&$element, FormStateInterface $form_state
* Properties used:
* - #ajax['event']
* - #ajax['prevent']
* - #ajax['path']
* - #ajax['url']
* - #ajax['options']
* - #ajax['wrapper']
* - #ajax['parameters']
......@@ -248,8 +249,13 @@ public static function preRenderAjaxForm($element) {
}
// Change path to URL.
$settings['url'] = isset($settings['path']) ? _url($settings['path'], $settings['options']) : NULL;
unset($settings['path'], $settings['options']);
if (isset($settings['url']) && $settings['url'] instanceof Url) {
$settings['url'] = $settings['url']->setOptions($settings['options'])->toString();
}
else {
$settings['url'] = NULL;
}
unset($settings['options']);
// Add special data to $settings['submit'] so that when this element
// triggers an Ajax submission, Drupal's form processing can determine which
......
......@@ -38,6 +38,12 @@ protected function getRoute($name) {
if ($name === '<front>') {
return new Route('/');
}
elseif ($name === '<current>') {
return new Route($this->requestStack->getCurrentRequest()->getPathInfo());
}
elseif ($name === '<none>') {
return new Route('');
}
throw new RouteNotFoundException();
}
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Utility\String;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Utility\UnroutedUrlAssemblerInterface;
......@@ -86,6 +87,13 @@ class Url {
*/
protected $uri;
/**
* Stores the internal path, if already requested by getInternalPath
*
* @var string
*/
protected $internalPath;
/**
* Constructs a new Url object.
*
......@@ -165,6 +173,23 @@ public static function fromRoute($route_name, $route_parameters = array(), $opti
return new static($route_name, $route_parameters, $options);
}
/**
* Creates a new URL object from a route match.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match.
*
* @return $this
*/
public static function fromRouteMatch(RouteMatchInterface $route_match) {
if ($route_match->getRouteObject()) {
return new static($route_match->getRouteName(), $route_match->getRawParameters()->all());
}
else {
throw new \InvalidArgumentException('Route required');
}
}
/**
* Creates a new Url object for a URI that does not have a Drupal route.
*
......@@ -510,7 +535,11 @@ public function getInternalPath() {
if ($this->unrouted) {
throw new \UnexpectedValueException('Unrouted URIs do not have internal representations.');
}
return $this->urlGenerator()->getPathFromRoute($this->getRouteName(), $this->getRouteParameters());
if (!isset($this->internalPath)) {
$this->internalPath = $this->urlGenerator()->getPathFromRoute($this->getRouteName(), $this->getRouteParameters());
}
return $this->internalPath;
}
/**
......@@ -582,12 +611,13 @@ protected function unroutedUrlAssembler() {
* Sets the URL generator.
*
* @param \Drupal\Core\Routing\UrlGeneratorInterface
* The URL generator.
* (optional) The URL generator, specify NULL to reset it.
*
* @return $this
*/
public function setUrlGenerator(UrlGeneratorInterface $url_generator) {
public function setUrlGenerator(UrlGeneratorInterface $url_generator = NULL) {
$this->urlGenerator = $url_generator;
$this->internalPath = NULL;
return $this;
}
......
......@@ -9,7 +9,7 @@
* page. The request returns an array of commands encoded in JSON, which is
* then executed to make any changes that are necessary to the page.
*
* Drupal uses this file to enhance form elements with #ajax['path'] and
* Drupal uses this file to enhance form elements with #ajax['url'] and
* #ajax['wrapper'] properties. If set, this file will automatically be included
* to provide Ajax capabilities.
*/
......
......@@ -326,7 +326,7 @@ if (window.jQuery) {
* Returns the URL to a Drupal page.
*/
Drupal.url = function (path) {
return drupalSettings.path.basePath + drupalSettings.path.scriptPath + drupalSettings.path.pathPrefix + path;
return drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + path;
};
/**
......
......@@ -173,7 +173,7 @@
* The transliterated source string.
*/
transliterate: function (source, settings) {
return $.get(drupalSettings.path.basePath + 'machine_name/transliterate', {
return $.get(Drupal.url('machine_name/transliterate'), {
text: source,
langcode: drupalSettings.langcode,
replace_pattern: settings.replace_pattern,
......
......@@ -469,7 +469,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
'#options' => $formatters,
'#default_value' => $this->options['type'],
'#ajax' => array(
'path' => views_ui_build_form_path($form_state),
'url' => views_ui_build_form_url($form_state),
),
'#submit' => array(array($this, 'submitTemporaryForm')),
'#executes_submit_callback' => TRUE,
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\FormElement;
use Drupal\Core\Url;
use Drupal\file\Entity\File;
/**
......@@ -144,7 +145,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
$element['#tree'] = TRUE;
$ajax_settings = [
'path' => 'file/ajax',
'url' => Url::fromRoute('file.ajax_upload'),
'options' => [
'query' => [
'element_parents' => implode('/', $element['#array_parents']),
......@@ -219,7 +220,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
}
// Add the upload progress callback.
$element['upload_button']['#ajax']['progress']['path'] = 'file/progress/' . $upload_progress_key;
$element['upload_button']['#ajax']['progress']['url'] = Url::fromRoute('file.ajax_progress');
}
// The file upload field itself.
......
......@@ -15,6 +15,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\file\Element\ManagedFile;
use Drupal\Core\Url;
/**
* Plugin implementation of the 'file_generic' widget.
......@@ -381,7 +382,7 @@ public static function process($element, FormStateInterface $form_state, $form)
// file, the entire group of file fields is updated together.
if ($element['#cardinality'] != 1) {
$parents = array_slice($element['#array_parents'], 0, -1);
$new_path = 'file/ajax';
$new_url = Url::fromRoute('file.ajax_upload');
$new_options = array(
'query' => array(
'element_parents' => implode('/', $parents),
......@@ -392,7 +393,7 @@ public static function process($element, FormStateInterface $form_state, $form)
$new_wrapper = $field_element['#id'] . '-ajax-wrapper';
foreach (Element::children($element) as $key) {
if (isset($element[$key]['#ajax'])) {
$element[$key]['#ajax']['path'] = $new_path;
$element[$key]['#ajax']['url'] = $new_url->setOptions($new_options);
$element[$key]['#ajax']['options'] = $new_options;
$element[$key]['#ajax']['wrapper'] = $new_wrapper;
}
......
......@@ -297,7 +297,7 @@ function shortcut_preprocess_page(&$variables) {
// we do not want to display it on "access denied" or "page not found"
// pages).
if (shortcut_set_edit_access()->isAllowed() && !\Drupal::request()->attributes->has('exception')) {
$link = current_path();
$link = Url::fromRouteMatch(\Drupal::routeMatch())->getInternalPath();
$route_match = \Drupal::routeMatch();
$query = array(
......
......@@ -164,13 +164,6 @@ protected function setUp() {
->set('interface.default', 'test_mail_collector')
->save();
// When running from run-tests.sh we don't get an empty current path which
// would indicate we're on the home page.
$path = current_path();
if (empty($path)) {
_current_path('run-tests');
}
$this->isInstalled = TRUE;
}
......
......@@ -932,12 +932,6 @@ protected function setUp() {
// DrupalKernel::prepareLegacyRequest() -> DrupalKernel::boot() but that
// appears to be calling a different container.
$this->container->get('stream_wrapper_manager')->register();
// Temporary fix so that when running from run-tests.sh we don't get an
// empty current path which would indicate we're on the home page.
$path = current_path();
if (empty($path)) {
_current_path('run-tests');
}
}
/**
......
......@@ -42,6 +42,9 @@ protected function setUp() {
// Reset _drupal_add_js() statics before each test.
drupal_static_reset('_drupal_add_js');
$this->installSchema('system', 'router');
\Drupal::service('router.builder')->rebuild();
}
protected function tearDown() {
......@@ -156,7 +159,7 @@ function testHeaderSetting() {
$this->render($attached);
$javascript = drupal_get_js('header');
$this->assertTrue(strpos($javascript, 'basePath') > 0, 'Rendered JavaScript header returns basePath setting.');
$this->assertTrue(strpos($javascript, 'baseUrl') > 0, 'Rendered JavaScript header returns baseUrl setting.');
$this->assertTrue(strpos($javascript, 'scriptPath') > 0, 'Rendered JavaScript header returns scriptPath setting.');
$this->assertTrue(strpos($javascript, 'pathPrefix') > 0, 'Rendered JavaScript header returns pathPrefix setting.');
$this->assertTrue(strpos($javascript, 'currentPath') > 0, 'Rendered JavaScript header returns currentPath setting.');
......
......@@ -21,7 +21,10 @@ class PageRenderTest extends KernelTestBase {
* Tests hook_page_attachments() exceptions.
*/
function testHookPageAttachmentsExceptions() {
$this->enableModules(['common_test']);
$this->enableModules(['common_test', 'system']);
$this->installSchema('system', 'router');
\Drupal::service('router.builder')->rebuild();
$this->assertPageRenderHookExceptions('common_test', 'hook_page_attachments');
}
......@@ -29,7 +32,10 @@ function testHookPageAttachmentsExceptions() {
* Tests hook_page_attachments_alter() exceptions.
*/
function testHookPageAlter() {
$this->enableModules(['common_test']);
$this->enableModules(['common_test', 'system']);
$this->installSchema('system', 'router');
\Drupal::service('router.builder')->rebuild();
$this->assertPageRenderHookExceptions('common_test', 'hook_page_attachments_alter');
}
......
......@@ -74,15 +74,6 @@ function testUrlAlter() {
$this->assertUrlOutboundAlter("forum/" . $term->id(), "community/" . $term->id());
}
/**
* Test current_path() and request_path().
*/
function testCurrentUrlRequestedPath() {
$this->drupalGet('url-alter-test/bar');
$this->assertRaw('request_path=url-alter-test/bar', 'request_path() returns the requested path.');
$this->assertRaw('current_path=url-alter-test/foo', 'current_path() returns the internal path.');
}
/**
* Assert that an outbound path is altered to an expected value.
*
......
......@@ -23,6 +23,16 @@ class TableTest extends DrupalUnitTestBase {
*/
public static $modules = array('system');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('system', 'router');
\Drupal::service('router.builder')->rebuild();
}
/**
* Tableheader.js provides 'sticky' table headers, and is included by default.
*/
......
......@@ -10,6 +10,9 @@
use Drupal\Component\Serialization\Json;
use Drupal\simpletest\WebTestBase;
use Drupal\test_theme\ThemeClass;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
/**
* Tests low-level theme functions.
......@@ -137,14 +140,16 @@ public function testThemeOnNonHtmlRequest() {
* Ensure page-front template suggestion is added when on front page.
*/
function testFrontPageThemeSuggestion() {
$original_path = _current_path();
// Set the current path to node because theme_get_suggestions() will query
// it to see if we are on the front page.
\Drupal::config('system.site')->set('page.front', 'node')->save();
_current_path('node');
$suggestions = theme_get_suggestions(array('node'), 'page');
// Set the current route to user.login because theme_get_suggestions() will
// query it to see if we are on the front page.
$request = Request::create('/user/login');
$request->attributes->set(RouteObjectInterface::ROUTE_NAME, 'user.login');
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/user/login'));
\Drupal::requestStack()->push($request);
\Drupal::config('system.site')->set('page.front', 'user/login')->save();
$suggestions = theme_get_suggestions(array('user', 'login'), 'page');
// Set it back to not annoy the batch runner.
_current_path($original_path);
\Drupal::requestStack()->pop();
$this->assertTrue(in_array('page__front', $suggestions), 'Front page template was suggested.');
}
......
......@@ -237,7 +237,12 @@ function system_hook_info() {
* Implements hook_theme_suggestions_HOOK().
*/
function system_theme_suggestions_html(array $variables) {
$path_args = explode('/', current_path());
if (\Drupal::service('path.matcher')->isFrontPage()) {
$path_args = [''];
}
else {
$path_args = explode('/', Url::fromRoute('<current>')->getInternalPath());
}
return theme_get_suggestions($path_args, 'html');
}
......@@ -245,7 +250,12 @@ function system_theme_suggestions_html(array $variables) {
* Implements hook_theme_suggestions_HOOK().
*/
function system_theme_suggestions_page(array $variables) {
$path_args = explode('/', current_path());
if (\Drupal::service('path.matcher')->isFrontPage()) {
$path_args = [''];
}
else {
$path_args = explode('/', Url::fromRoute('<current>')->getInternalPath());
}
return theme_get_suggestions($path_args, 'page');
}
......@@ -612,7 +622,7 @@ function system_page_attachments(array &$page) {
$page['#post_render_cache']['\Drupal\system\Controller\SystemController::setLinkActiveClass'] = array(
// Collect the current state that determines whether a link is active.
array(
'path' => current_path(),
'path' => \Drupal::routeMatch()->getRouteName() ? Url::fromRouteMatch(\Drupal::routeMatch())->getInternalPath() : '',
'front' => drupal_is_front_page(),
'language' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(),
'query' => \Drupal::request()->query->all(),
......
<?php
/**
* @file
* Contains \Drupal\url_alter_test\Controller\URLAlterTestController.
*/
namespace Drupal\url_alter_test\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
* Controller routines for url_alter_test routes.
*/
class URLAlterTestController {