diff --git a/core/includes/entity.api.php b/core/includes/entity.api.php index b25c38f..b966b82 100644 --- a/core/includes/entity.api.php +++ b/core/includes/entity.api.php @@ -323,7 +323,7 @@ function hook_entity_view(\Drupal\Core\Entity\EntityInterface $entity, \Drupal\e // Only do the extra work if the component is configured to be displayed. // This assumes a 'mymodule_addition' extra field has been defined for the // entity bundle in hook_field_extra_fields(). - if ($display->getComponent('mymodule_addition')) { + if ($display->getComponent('extra_field', 'mymodule_addition')) { $entity->content['mymodule_addition'] = array( '#markup' => mymodule_addition($entity), '#theme' => 'mymodule_my_additional_field', @@ -393,7 +393,7 @@ function hook_entity_prepare_view($entity_type, array $entities, array $displays // defined for the entity bundle in hook_field_extra_fields(). $ids = array(); foreach ($entities as $id => $entity) { - if ($displays[$entity->bundle()]->getComponent('mymodule_addition')) { + if ($displays[$entity->bundle()]->getComponent('extra_field', 'mymodule_addition')) { $ids[] = $id; } } diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php index cb4133d..e0abadd 100644 --- a/core/modules/comment/comment.api.php +++ b/core/modules/comment/comment.api.php @@ -95,7 +95,7 @@ function hook_comment_view(\Drupal\comment\Plugin\Core\Entity\Comment $comment, // Only do the extra work if the component is configured to be displayed. // This assumes a 'mymodule_addition' extra field has been defined for the // node type in hook_field_extra_fields(). - if ($display->getComponent('mymodule_addition')) { + if ($display->getComponent('extra_field', 'mymodule_addition')) { $comment->content['mymodule_addition'] = array( '#markup' => mymodule_addition($comment), '#theme' => 'mymodule_my_additional_field', diff --git a/core/modules/contact/lib/Drupal/contact/MessageRenderController.php b/core/modules/contact/lib/Drupal/contact/MessageRenderController.php index b3a8a31..eb51b2c 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageRenderController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageRenderController.php @@ -24,7 +24,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang foreach ($entities as $entity) { // Add the message extra field, if enabled. $display = $displays[$entity->bundle()]; - if (!empty($entity->message) && $display->getComponent('message')) { + if (!empty($entity->message) && $display->getComponent('extra_field', 'message')) { $entity->content['message'] = array( '#type' => 'item', '#title' => t('Message'), diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php index 75388ae..7316099 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php @@ -51,7 +51,7 @@ function setUp() { protected function getSelectedEditor($items, $field_name, $view_mode = 'default') { $options = entity_get_display('test_entity', 'test_bundle', $view_mode)->getComponent('field', $field_name); $field_instance = field_info_instance('test_entity', $field_name, 'test_bundle'); - return $this->editorSelector->getEditor($options['type'], $field_instance, $items); + return $this->editorSelector->getEditor($options['formatter'], $field_instance, $items); } /** diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php index d0a4084..2916dca 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php @@ -347,6 +347,11 @@ public function getHighestWeight() { $weights[] = $options['weight']; } } + + // Let other modules feedback about their own additions. + $weights = array_merge($weights, module_invoke_all('field_info_max_weight', $this->targetEntityType, $this->bundle, $this->viewMode)); + + return $weights ? max($weights) : NULL; } } diff --git a/core/modules/node/lib/Drupal/node/NodeRenderController.php b/core/modules/node/lib/Drupal/node/NodeRenderController.php index e829e40..28fe039 100644 --- a/core/modules/node/lib/Drupal/node/NodeRenderController.php +++ b/core/modules/node/lib/Drupal/node/NodeRenderController.php @@ -71,7 +71,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang ); // Add Language field text element to node render array. - if ($display->getComponent('language')) { + if ($display->getComponent('extra_field', 'language')) { $entity->content['language'] = array( '#type' => 'item', '#title' => t('Language'), diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index f4e3d3d..f8629c5 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -872,7 +872,7 @@ function hook_node_view(\Drupal\node\Plugin\Core\Entity\Node $node, \Drupal\enti // Only do the extra work if the component is configured to be displayed. // This assumes a 'mymodule_addition' extra field has been defined for the // node type in hook_field_extra_fields(). - if ($display->getComponent('mymodule_addition')) { + if ($display->getComponent('extra_field', 'mymodule_addition')) { $node->content['mymodule_addition'] = array( '#markup' => mymodule_addition($node), '#theme' => 'mymodule_my_additional_field', @@ -1344,7 +1344,7 @@ function hook_view(\Drupal\node\Plugin\Core\Entity\Node $node, \Drupal\entity\Pl // Only do the extra work if the component is configured to be displayed. // This assumes a 'mymodule_addition' extra field has been defined for the // node type in hook_field_extra_fields(). - if ($display->getComponent('mymodule_addition')) { + if ($display->getComponent('extra_field', 'mymodule_addition')) { $node->content['mymodule_addition'] = array( '#markup' => mymodule_addition($node), '#theme' => 'mymodule_my_additional_field', diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php index ce8cb03..de72bbe 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php @@ -25,7 +25,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang foreach ($entities as $entity) { // Add the description if enabled. $display = $displays[$entity->bundle()]; - if (!empty($entity->description) && $display->getComponent('description')) { + if (!empty($entity->description) && $display->getComponent('extra_field', 'description')) { $entity->content['description'] = array( '#markup' => check_markup($entity->description, $entity->format, '', TRUE), '#prefix' => '
', diff --git a/core/modules/taxonomy/taxonomy.api.php b/core/modules/taxonomy/taxonomy.api.php index d2f41f6..a39f542 100644 --- a/core/modules/taxonomy/taxonomy.api.php +++ b/core/modules/taxonomy/taxonomy.api.php @@ -277,7 +277,7 @@ function hook_taxonomy_term_view(\Drupal\taxonomy\Plugin\Core\Entity\Term $term, // Only do the extra work if the component is configured to be displayed. // This assumes a 'mymodule_addition' extra field has been defined for the // vocabulary in hook_field_extra_fields(). - if ($display->getComponent('mymodule_addition')) { + if ($display->getComponent('extra_field', 'mymodule_addition')) { $term->content['mymodule_addition'] = array( '#markup' => mymodule_addition($term), '#theme' => 'mymodule_my_additional_field', diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php index 652c5b5..4201a70 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -363,7 +363,7 @@ function hook_user_view(\Drupal\user\Plugin\Core\Entity\User $account, \Drupal\e // Only do the extra work if the component is configured to be displayed. // This assumes a 'mymodule_addition' extra field has been defined for the // user entity type in hook_field_extra_fields(). - if ($display->getComponent('mymodule_addition')) { + if ($display->getComponent('extra_field', 'mymodule_addition')) { $account->content['mymodule_addition'] = array( '#markup' => mymodule_addition($account), '#theme' => 'mymodule_my_additional_field', diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 4500c9b..f07ba45 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -614,7 +614,7 @@ function user_search_execute($keys = NULL, $conditions = NULL) { * Implements hook_user_view(). */ function user_user_view(User $account, EntityDisplay $display) { - if ($display->getComponent('member_for')) { + if ($display->getComponent('extra_field', 'member_for')) { $account->content['member_for'] = array( '#type' => 'item', '#title' => t('Member for'),