diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 2786774..461ece9 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1519,18 +1519,6 @@ function template_preprocess_feed_icon(&$variables) {
}
/**
- * Returns HTML for a "more" link, like those used in blocks.
- *
- * @param $variables
- * An associative array containing:
- * - url: The URL of the main page.
- * - title: A descriptive verb for the link, like 'Read more'.
- */
-function theme_more_link($variables) {
- return '
' . l(t('More'), $variables['url'], array('attributes' => array('title' => $variables['title']))) . '
';
-}
-
-/**
* Returns HTML for an indentation div; used for drag and drop tables.
*
* @param $variables
@@ -2355,9 +2343,6 @@ function drupal_common_theme() {
'variables' => array('url' => NULL, 'title' => NULL),
'template' => 'feed-icon',
),
- 'more_link' => array(
- 'variables' => array('url' => NULL, 'title' => NULL)
- ),
'progress_bar' => array(
'variables' => array('label' => NULL, 'percent' => NULL, 'message' => NULL),
'template' => 'progress-bar',
diff --git a/core/lib/Drupal/Core/Render/Element/MoreLink.php b/core/lib/Drupal/Core/Render/Element/MoreLink.php
new file mode 100644
index 0000000..a8db83b
--- /dev/null
+++ b/core/lib/Drupal/Core/Render/Element/MoreLink.php
@@ -0,0 +1,33 @@
+ t('More'),
+ '#theme_wrappers' => array(
+ 'container' => array(
+ '#attributes' => array('class' => 'more-link'),
+ ),
+ ),
+ ) + $info;
+ }
+
+}
diff --git a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php
index 4fcb464..65f95f1 100644
--- a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php
+++ b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php
@@ -163,9 +163,9 @@ public function build() {
$items = $this->itemStorage->loadMultiple($result);
$more_link = array(
- '#theme' => 'more_link',
- '#url' => 'aggregator/sources/' . $feed->id(),
- '#title' => t("View this feed's recent news."),
+ '#type' => 'more_link',
+ '#href' => 'aggregator/sources/' . $feed->id(),
+ '#attributes' => array('title' => $this->t("View this feed's recent news.")),
);
$read_more = drupal_render($more_link);
$rendered_items = array();
diff --git a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php
index 8e690f0..88d4780 100644
--- a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php
+++ b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php
@@ -26,9 +26,9 @@ public function build() {
if ($node_title_list = node_title_list($result)) {
$elements['forum_list'] = $node_title_list;
$elements['forum_more'] = array(
- '#theme' => 'more_link',
- '#url' => 'forum',
- '#title' => t('Read the latest forum topics.')
+ '#type' => 'more_link',
+ '#href' => 'forum',
+ '#attributes' => array('title' => t('Read the latest forum topics.')),
);
}
return $elements;
diff --git a/core/modules/system/css/system.theme.css b/core/modules/system/css/system.theme.css
index 7023b4f..d415710 100644
--- a/core/modules/system/css/system.theme.css
+++ b/core/modules/system/css/system.theme.css
@@ -129,7 +129,7 @@ abbr.ajax-changed {
}
/**
- * Markup generated by theme_more_link().
+ * Markup generated by #type 'more_link'.
*/
.more-link {
display: block;
diff --git a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php
index 8d53fe4..6d83838 100644
--- a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php
+++ b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php
@@ -22,11 +22,13 @@ class RenderElementTypesTest extends DrupalUnitTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = array('system', 'router_test');
protected function setUp() {
parent::setUp();
$this->installConfig(array('system'));
+ $this->installSchema('system', array('router'));
+ \Drupal::service('router.builder')->rebuild();
}
/**
@@ -101,4 +103,85 @@ function testHtmlTag() {
), "title test\n", "#type 'html_tag' title tag generation");
}
+ /**
+ * Tests system #type 'more_link'.
+ */
+ function testMoreLink() {
+ $elements = array(
+ array(
+ 'name' => "#type 'more_link' anchor tag generation without extra classes",
+ 'value' => array(
+ '#type' => 'more_link',
+ '#href' => 'http://drupal.org',
+ ),
+ 'expected' => '//div[@class="more-link"]/a[@href="http://drupal.org" and text()="More"]',
+ ),
+ array(
+ 'name' => "#type 'more_link' anchor tag generation with different link text",
+ 'value' => array(
+ '#type' => 'more_link',
+ '#href' => 'http://drupal.org',
+ '#title' => 'More Titles',
+ ),
+ 'expected' => '//div[@class="more-link"]/a[@href="http://drupal.org" and text()="More Titles"]',
+ ),
+ array(
+ 'name' => "#type 'more_link' anchor tag generation with attributes on wrapper",
+ 'value' => array(
+ '#type' => 'more_link',
+ '#href' => 'http://drupal.org',
+ '#theme_wrappers' => array(
+ 'container' => array(
+ '#attributes' => array(
+ 'title' => 'description',
+ 'class' => array('more-link', 'drupal', 'test'),
+ ),
+ ),
+ ),
+ ),
+ 'expected' => '//div[@title="description" and contains(@class, "more-link") and contains(@class, "drupal") and contains(@class, "test")]/a[@href="http://drupal.org" and text()="More"]',
+ ),
+ array(
+ 'name' => "#type 'more_link' anchor tag with a relative path",
+ 'value' => array(
+ '#type' => 'more_link',
+ '#href' => 'a/link',
+ ),
+ 'expected' => '//div[@class="more-link"]/a[@href="' . url('a/link') . '" and text()="More"]',
+ ),
+ array(
+ 'name' => "#type 'more_link' anchor tag with a route",
+ 'value' => array(
+ '#type' => 'more_link',
+ '#route_name' => 'router_test.1',
+ '#route_parameters' => array(),
+ ),
+ 'expected' => '//div[@class="more-link"]/a[@href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" and text()="More"]',
+ ),
+ array(
+ 'name' => "#type 'more_link' anchor tag with an absolute path",
+ 'value' => array(
+ '#type' => 'more_link',
+ '#href' => 'admin/content',
+ '#options' => array('absolute' => TRUE),
+ ),
+ 'expected' => '//div[@class="more-link"]/a[@href="' . url('admin/content', array('absolute' => TRUE)) . '" and text()="More"]',
+ ),
+ array(
+ 'name' => "#type 'more_link' anchor tag to the front page",
+ 'value' => array(
+ '#type' => 'more_link',
+ '#href' => '',
+ ),
+ 'expected' => '//div[@class="more-link"]/a[@href="' . url('') . '" and text()="More"]',
+ ),
+ );
+
+ foreach($elements as $element) {
+ $xml = new \SimpleXMLElement(drupal_render($element['value']));
+ $result = $xml->xpath($element['expected']);
+ $this->assertTrue($result, '"' . $element['name'] . '" input rendered correctly by drupal_render().');
+ }
+ }
+
}
diff --git a/core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php b/core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php
index 0cdf668..a02be18 100644
--- a/core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php
+++ b/core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php
@@ -43,9 +43,9 @@ public function onRequest(GetResponseEvent $event) {
// theme system is initialized this early, it is still capable of
// returning output and theming the page as a whole.
$more_link = array(
- '#theme' => 'more_link',
- '#url' => 'user',
- '#title' => 'Themed output generated in a KernelEvents::REQUEST listener',
+ '#type' => 'more_link',
+ '#href' => 'user',
+ '#attributes' => array('title' => 'Themed output generated in a KernelEvents::REQUEST listener'),
);
$GLOBALS['theme_test_output'] = drupal_render($more_link);
}