diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index f567558..b44a7f6 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -110,8 +110,10 @@ 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'])) { + // @todo Inject these services, or abstract to a dedicated class. + $options = []; + $system_path = \Drupal::service('path_processor_manager')->processOutbound($url->getInternalPath(), $options, \Drupal::request()); // @todo System path is deprecated - use the route name and parameters. - $system_path = $url->getInternalPath(); // Special case for the front page. $variables['options']['attributes']['data-drupal-link-system-path'] = $system_path == '' ? '' : $system_path; } diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index e1242fb..e50e70d 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -80,8 +80,10 @@ public function viewElements(FieldItemListInterface $items) { ); if (!empty($item->_attributes)) { - $elements[$delta]['#options'] += array('attributes' => array()); - $elements[$delta]['#options']['attributes'] += $item->_attributes; + $options = $elements[$delta]['#url']->getOptions(); + $options += array('attributes' => array()); + $options['attributes'] += $item->_attributes; + $elements[$delta]['#url']->setOptions($options); // Unset field item attributes since they have been included in the // formatter output and shouldn't be rendered in the field template. unset($item->_attributes); diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index ff21395..2379899 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -106,7 +106,7 @@ function manageFieldsPage($type = '') { $url = base_path() . "admin/structure/types/manage/$type/fields/node.$type.body"; $this->assertIdentical($url, (string) $result[0]['href']); $this->assertIdentical("$url/storage", (string) $result[1]['href']); - $this->assertIdentical("$url/delete", (string) $result[3]['href']); + $this->assertIdentical("$url/delete", (string) $result[2]['href']); } /** 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 9631c55..e158350 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -385,12 +385,18 @@ function entity_test_entity_predelete(EntityInterface $entity) { * Implements hook_entity_operation_alter(). */ function entity_test_entity_operation_alter(array &$operations, EntityInterface $entity) { - 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, - ); + $valid_entity_type_ids = [ + 'user_role', + 'block', + ]; + if (in_array($entity->getEntityTypeId(), $valid_entity_type_ids)) { + 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, + ); + } } }