diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 51cf4a7..a518db1 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1010,13 +1010,14 @@ function template_preprocess_links(&$variables) { /** @var \Drupal\Core\Url $url */ $url = $link['url']; - - // Add a "data-drupal-link-system-path" attribute to let the - // drupal.active-link library know the path in a standardized manner. - $system_path = $url->getInternalPath(); - // @todo System path is deprecated - use the route name and parameters. - // Special case for the front page. - $li_attributes['data-drupal-link-system-path'] = $system_path == '' ? '' : $system_path; + if ($url->isRouted()) { + // Add a "data-drupal-link-system-path" attribute to let the + // drupal.active-link library know the path in a standardized manner. + $system_path = $url->getInternalPath(); + // @todo System path is deprecated - use the route name and parameters. + // Special case for the front page. + $li_attributes['data-drupal-link-system-path'] = $system_path == '' ? '' : $system_path; + } } $item['link'] = $link_element; diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 85b0944..5e8dd44 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -456,12 +456,26 @@ public function toString() { * * @return array * An associative array containing all the properties of the route. + * + * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0. + * Most usecases should use the URL object directly, like #type links. Other + * usecases should get the information from the URL object manually. */ public function toArray() { - return [ - 'url' => $this, - 'options' => $this->getOptions(), - ]; + if ($this->unrouted) { + return array( + // @todo Change 'path' to 'href': https://www.drupal.org/node/2347025. + 'path' => $this->getUri(), + 'options' => $this->getOptions(), + ); + } + else { + return array( + 'route_name' => $this->getRouteName(), + 'route_parameters' => $this->getRouteParameters(), + 'options' => $this->getOptions(), + ); + } } /** diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index f567558..b029327 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -109,7 +109,7 @@ public function generate($text, Url $url) { // Add a "data-drupal-link-system-path" attribute to let the // drupal.active-link library know the path in a standardized manner. - if (!isset($variables['options']['attributes']['data-drupal-link-system-path'])) { + if ($url->isRouted() && !isset($variables['options']['attributes']['data-drupal-link-system-path'])) { // @todo System path is deprecated - use the route name and parameters. $system_path = $url->getInternalPath(); // Special case for the front page. diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 3719076..10b7366 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -129,6 +129,7 @@ function forum_menu_local_tasks(&$data, $route_name) { } $data['actions'] += $links; } + // @todo Bring back functionality in https://www.drupal.org/node/1853072. } /** diff --git a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php index 21e078f..e0666d9 100644 --- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php +++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php @@ -205,6 +205,8 @@ public function massageFormValues(array $values, array $form, FormStateInterface return $values; } + // @todo Don't use the toArray method here. Removed once it is + // deprecated. $value += $url->toArray(); // Reset the URL value to contain only the path. diff --git a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php index a3b525d..8e3433b 100644 --- a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php @@ -195,11 +195,6 @@ public function getEditRoute() { */ public function getTranslateRoute() { return $this->getEntity()->urlInfo('drupal:content-translation-overview'); - $entity_type = 'menu_link_content'; - return array( - 'route_name' => 'content_translation.translation_overview_' . $entity_type, - 'route_parameters' => array( $entity_type => $this->getEntity()->id()), - ); } /** diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index 4e68c57..0836987 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -742,6 +742,11 @@ protected function assertNoTitle($title, $message = '', $group = 'Other') { */ protected function assertThemeOutput($callback, array $variables = array(), $expected = '', $message = '', $group = 'Other') { $output = \Drupal::theme()->render($callback, $variables); + $this->verbose( + '
' . 'Result:' . '
' . String::checkPlain(var_export($output, TRUE)) . '
' + . '
' . 'Expected:' . '
' . String::checkPlain(var_export($expected, TRUE)) . '
' + . '
' . $output + ); if (!$message) { $message = '%callback rendered correctly.'; } diff --git a/core/modules/system/src/Tests/Common/RenderWebTest.php b/core/modules/system/src/Tests/Common/RenderWebTest.php index c2136dd..5d7f36e 100644 --- a/core/modules/system/src/Tests/Common/RenderWebTest.php +++ b/core/modules/system/src/Tests/Common/RenderWebTest.php @@ -147,7 +147,12 @@ function testDrupalRenderFormElements() { * Tests that elements are rendered properly. */ protected function assertRenderedElement(array $element, $xpath, array $xpath_args = array()) { + $original_element = $element; $this->drupalSetContent(drupal_render($element)); + $this->verbose('
' .  String::checkPlain(var_export($original_element, TRUE)) . '
' + . '
' .  String::checkPlain(var_export($element, TRUE)) . '
' + . '
' . $this->drupalGetContent() + ); // @see \Drupal\simpletest\WebTestBase::xpath() $xpath = $this->buildXPathQuery($xpath, $xpath_args); diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php index 9eeeb47..6433a64 100644 --- a/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -189,6 +189,10 @@ function testLinks() { $variables = array(); $variables['attributes'] = array('id' => 'somelinks'); $variables['links'] = array( + 'a link' => array( + 'title' => 'A ', + 'url' => Url::fromUri('base://a/link'), + ), 'plain text' => array( 'title' => 'Plain "text"', ), @@ -211,6 +215,7 @@ function testLinks() { $expected_links = ''; $expected_links .= '