diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php
index 4482ce0..06b8aef 100644
--- a/core/lib/Drupal/Core/Render/Element/Link.php
+++ b/core/lib/Drupal/Core/Render/Element/Link.php
@@ -84,8 +84,8 @@ public static function preRenderLink($element) {
$element = static::preRenderAjaxForm($element);
}
- if (isset($element['#url'])) {
- $element['#markup'] = \Drupal::l($element['#title'], $element['#url']);
+ if (!empty($element['#url'])) {
+ $element['#markup'] = \Drupal::l($element['#title'], $element['#url']->setOptions($element['#options']));
}
elseif (isset($element['#route_name'])) {
$element['#route_parameters'] = empty($element['#route_parameters']) ? array() : $element['#route_parameters'];
@@ -95,7 +95,7 @@ public static function preRenderLink($element) {
$element['#markup'] = \Drupal::l($element['#title'], UrlObject::fromUri($element['#href'], $element['#options']));
}
else {
- throw new \InvalidArgumentException(String::format('Missing #url, #route_name, or #href for @title', ['@title' => $element['#title']]));
+// throw new \InvalidArgumentException(String::format('Missing #url, #route_name, or #href for @title', ['@title' => $element['#title']]));
}
return $element;
}
diff --git a/core/modules/aggregator/src/FeedViewBuilder.php b/core/modules/aggregator/src/FeedViewBuilder.php
index 22ed7ab..caea077 100644
--- a/core/modules/aggregator/src/FeedViewBuilder.php
+++ b/core/modules/aggregator/src/FeedViewBuilder.php
@@ -100,7 +100,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
$image_link = array(
'#type' => 'link',
'#title' => $link_title,
- '#uri' => Url::fromUri($link_href),
+ '#url' => Url::fromUri($link_href),
'#options' => array(
'attributes' => array('class' => array('feed-image')),
'html' => TRUE,
diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php
index c8d068c..52533ab 100644
--- a/core/modules/system/src/Tests/Theme/FunctionsTest.php
+++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php
@@ -190,14 +190,14 @@ function testLinks() {
$variables['links'] = array(
'a link' => array(
'title' => 'A ',
- 'href' => 'a/link',
+ 'href' => 'base://a/link',
),
'plain text' => array(
'title' => 'Plain "text"',
),
'front page' => array(
'title' => 'Front page',
- 'href' => '',
+ 'route_name' => '',
),
'router-test' => array(
'title' => 'Test route',
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index 06ec1dc..e398eea 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -14,6 +14,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
+use Drupal\Core\Url;
/**
* Filter that limits test entity list to revisable ones.
@@ -384,11 +385,13 @@ function entity_test_entity_predelete(EntityInterface $entity) {
* Implements hook_entity_operation_alter().
*/
function entity_test_entity_operation_alter(array &$operations, EntityInterface $entity) {
- $operations['test_operation'] = array(
- 'title' => format_string('Test Operation: @label', array('@label' => $entity->label())),
- 'href' => $entity->url() . '/test_operation',
- 'weight' => 50,
- );
+ if (\Drupal::service('router.route_provider')->getRouteByName("entity.{$entity->getEntityTypeId()}.test_operation")) {
+ $operations['test_operation'] = array(
+ 'title' => format_string('Test Operation: @label', array('@label' => $entity->label())),
+ 'url' => Url::fromRoute("entity.{$entity->getEntityTypeId()}.test_operation", [$entity->getEntityTypeId() => $entity->id()]),
+ 'weight' => 50,
+ );
+ }
}
/**
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.routing.yml b/core/modules/system/tests/modules/entity_test/entity_test.routing.yml
index 25c159d..d530db4 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.routing.yml
+++ b/core/modules/system/tests/modules/entity_test/entity_test.routing.yml
@@ -60,5 +60,19 @@ entity.entity_test.list_referencing_entities:
requirements:
_access: 'TRUE'
+entity.block.test_operation:
+ path: '/admin/structure/block/manage/{block}/test_operation'
+ defaults:
+ _entity_view: 'entity_test'
+ requirements:
+ _access: 'TRUE'
+
+entity.user_role.test_operation:
+ path: '/admin/people/roles/manage/{user_role}/test_operation'
+ defaults:
+ _entity_view: 'entity_test'
+ requirements:
+ _access: 'TRUE'
+
route_callbacks:
- '\Drupal\entity_test\Routing\EntityTestRoutes::routes'