diff --git a/core/includes/entity.api.php b/core/includes/entity.api.php index da9c1b8..314e8c6 100644 --- a/core/includes/entity.api.php +++ b/core/includes/entity.api.php @@ -339,8 +339,6 @@ function hook_entity_query_alter(\Drupal\Core\Entity\Query\QueryInterface $query * entity components. * @param $view_mode * The view mode the entity is rendered in. - * @param $langcode - * The language code used for rendering. * * The module may add elements to $entity->content prior to rendering. The * structure of $entity->content is a renderable array as expected by @@ -351,7 +349,7 @@ function hook_entity_query_alter(\Drupal\Core\Entity\Query\QueryInterface $query * @see hook_node_view() * @see hook_user_view() */ -function hook_entity_view(\Drupal\Core\Entity\EntityInterface $entity, \Drupal\entity\Entity\EntityDisplay $display, $view_mode, $langcode) { +function hook_entity_view(\Drupal\Core\Entity\EntityInterface $entity, \Drupal\entity\Entity\EntityDisplay $display, $view_mode) { // 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(). diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 8071a0d..775bc7a 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -626,10 +626,10 @@ function entity_render_controller($entity_type) { * @return array * A render array for the entity. */ -function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL) { +function entity_view(EntityInterface $entity, $view_mode) { return Drupal::entityManager() ->getRenderController($entity->entityType()) - ->view($entity, $view_mode, $langcode); + ->view($entity, $view_mode); } /** @@ -647,10 +647,10 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL) { * A render array for the entities, indexed by the same keys as the * entities array passed in $entities. */ -function entity_view_multiple(array $entities, $view_mode, $langcode = NULL) { +function entity_view_multiple(array $entities, $view_mode) { return Drupal::entityManager() ->getRenderController(reset($entities)->entityType()) - ->viewMultiple($entities, $view_mode, $langcode); + ->viewMultiple($entities, $view_mode); } /** diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php index b9667d2..2f163e4 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php @@ -60,10 +60,10 @@ public static function create(ContainerInterface $container) { * @return array * A render array as expected by drupal_render(). */ - public function view(EntityInterface $_entity, $view_mode = 'full', $langcode = NULL) { + public function view(EntityInterface $_entity, $view_mode = 'full') { return $this->entityManager ->getRenderController($_entity->entityType()) - ->view($_entity, $view_mode, $langcode); + ->view($_entity, $view_mode); } } diff --git a/core/lib/Drupal/Core/Entity/EntityRenderController.php b/core/lib/Drupal/Core/Entity/EntityRenderController.php index 860c044..43e6e80 100644 --- a/core/lib/Drupal/Core/Entity/EntityRenderController.php +++ b/core/lib/Drupal/Core/Entity/EntityRenderController.php @@ -29,8 +29,8 @@ public function __construct($entity_type) { /** * Implements \Drupal\Core\Entity\EntityRenderControllerInterface::buildContent(). */ - public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) { - field_attach_prepare_view($this->entityType, $entities, $displays, $langcode); + public function buildContent(array $entities, array $displays, $view_mode) { + field_attach_prepare_view($this->entityType, $entities, $displays); module_invoke_all('entity_prepare_view', $this->entityType, $entities, $displays, $view_mode); foreach ($entities as $entity) { @@ -38,7 +38,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang $entity->content = array( '#view_mode' => $view_mode, ); - $entity->content += field_attach_view($entity, $displays[$entity->bundle()], $langcode); + $entity->content += field_attach_view($entity, $displays[$entity->bundle()]); } } @@ -49,18 +49,14 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang * The entity for which the defaults should be provided. * @param string $view_mode * The view mode that should be used. - * @param string $langcode - * (optional) For which language the entity should be prepared, defaults to - * the current content language. * * @return array */ - protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { + protected function getBuildDefaults(EntityInterface $entity, $view_mode) { $return = array( '#theme' => $this->entityType, "#{$this->entityType}" => $entity, '#view_mode' => $view_mode, - '#langcode' => $langcode, ); return $return; } @@ -77,38 +73,30 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco * the entity components. * @param string $view_mode * The view mode that should be used to prepare the entity. - * @param string $langcode - * (optional) For which language the entity should be prepared, defaults to - * the current content language. */ - protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) { } + protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode) { } /** * Implements \Drupal\Core\Entity\EntityRenderControllerInterface::view(). */ - public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { - $buildList = $this->viewMultiple(array($entity), $view_mode, $langcode); + public function view(EntityInterface $entity, $view_mode = 'full') { + $buildList = $this->viewMultiple(array($entity), $view_mode); return $buildList[0]; } /** * Implements \Drupal\Core\Entity\EntityRenderControllerInterface::viewMultiple(). */ - public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = language(Language::TYPE_CONTENT)->id; - } - + public function viewMultiple(array $entities = array(), $view_mode = 'full') { // Build the view modes and display objects. $view_modes = array(); $displays = array(); - $context = array('langcode' => $langcode); foreach ($entities as $entity) { $bundle = $entity->bundle(); // Allow modules to change the view mode. $entity_view_mode = $view_mode; - drupal_alter('entity_view_mode', $entity_view_mode, $entity, $context); + drupal_alter('entity_view_mode', $entity_view_mode, $entity); // Store entities for rendering by view_mode. $view_modes[$entity_view_mode][$entity->id()] = $entity; @@ -130,7 +118,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la } foreach ($view_modes as $mode => $view_mode_entities) { - $this->buildContent($view_mode_entities, $displays[$mode], $mode, $langcode); + $this->buildContent($view_mode_entities, $displays[$mode], $mode); } $view_hook = "{$this->entityType}_view"; @@ -139,15 +127,15 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la foreach ($entities as $key => $entity) { $entity_view_mode = isset($entity->content['#view_mode']) ? $entity->content['#view_mode'] : $view_mode; $display = $displays[$entity_view_mode][$entity->bundle()]; - module_invoke_all($view_hook, $entity, $display, $entity_view_mode, $langcode); - module_invoke_all('entity_view', $entity, $display, $entity_view_mode, $langcode); + module_invoke_all($view_hook, $entity, $display, $entity_view_mode); + module_invoke_all('entity_view', $entity, $display, $entity_view_mode); $build[$key] = $entity->content; // We don't need duplicate rendering info in $entity->content. unset($entity->content); - $build[$key] += $this->getBuildDefaults($entity, $entity_view_mode, $langcode); - $this->alterBuild($build[$key], $entity, $display, $entity_view_mode, $langcode); + $build[$key] += $this->getBuildDefaults($entity, $entity_view_mode); + $this->alterBuild($build[$key], $entity, $display, $entity_view_mode); // Assign the weights configured in the display. foreach ($display->getComponents() as $name => $options) { diff --git a/core/lib/Drupal/Core/Entity/EntityRenderControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityRenderControllerInterface.php index 03ba014..941b101 100644 --- a/core/lib/Drupal/Core/Entity/EntityRenderControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityRenderControllerInterface.php @@ -22,14 +22,11 @@ * configured for the entity components, keyed by bundle name. * @param string $view_mode * The view mode in which the entity is being viewed. - * @param string $langcode - * (optional) For which language the entity should be build, defaults to - * the current content language. * * @return array * The content array. */ - public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL); + public function buildContent(array $entities, array $displays, $view_mode); /** * Returns the render array for the provided entity. @@ -38,9 +35,6 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang * The entity to render. * @param string $view_mode * (optional) The view mode that should be used to render the entity. - * @param string $langcode - * (optional) For which language the entity should be rendered, defaults to - * the current content language. * * @return array * A render array for the entity. @@ -51,7 +45,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang * comment belongs to, or not passing one, and having the comment node not * be available for loading. */ - public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL); + public function view(EntityInterface $entity, $view_mode = 'full'); /** * Returns the render array for the provided entities. @@ -60,9 +54,6 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N * An array of entities implementing EntityInterface to view. * @param string $view_mode * (optional) The view mode that should be used to render the entity. - * @param string $langcode - * (optional) For which language the entity should be rendered, defaults to - * the current content language. * * @return * A render array for the entities, indexed by the same keys as the @@ -74,5 +65,5 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N * comments belongs to, or not passing one, and having the comments node not * be available for loading. */ - public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL); + public function viewMultiple(array $entities = array(), $view_mode = 'full'); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedRenderController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedRenderController.php index 47de47b..3d73c51 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedRenderController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedRenderController.php @@ -18,8 +18,8 @@ class FeedRenderController extends EntityRenderController { /** * Overrides Drupal\Core\Entity\EntityRenderController::getBuildDefaults(). */ - protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { - $defaults = parent::getBuildDefaults($entity, $view_mode, $langcode); + protected function getBuildDefaults(EntityInterface $entity, $view_mode) { + $defaults = parent::getBuildDefaults($entity, $view_mode); $defaults['#theme'] = 'aggregator_feed_source'; return $defaults; } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/ItemRenderController.php b/core/modules/aggregator/lib/Drupal/aggregator/ItemRenderController.php index af11005..2f8e72d 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/ItemRenderController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/ItemRenderController.php @@ -18,8 +18,8 @@ class ItemRenderController extends EntityRenderController { /** * Overrides Drupal\Core\Entity\EntityRenderController::getBuildDefaults(). */ - protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { - $defaults = parent::getBuildDefaults($entity, $view_mode, $langcode); + protected function getBuildDefaults(EntityInterface $entity, $view_mode) { + $defaults = parent::getBuildDefaults($entity, $view_mode); // Use a different template for the summary view mode. if ($view_mode == 'summary') { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php index 3457115..a83eef8 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php @@ -19,8 +19,8 @@ class CustomBlockRenderController extends EntityRenderController { /** * Overrides \Drupal\Core\Entity\EntityRenderController::alterBuild(). */ - protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) { - parent::alterBuild($build, $entity, $display, $view_mode, $langcode); + protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode) { + parent::alterBuild($build, $entity, $display, $view_mode); // Add contextual links for this custom block. if (!empty($entity->id->value) && $view_mode == 'full') { $build['#contextual_links']['custom_block'] = array('block', array($entity->id())); diff --git a/core/modules/block/lib/Drupal/block/BlockRenderController.php b/core/modules/block/lib/Drupal/block/BlockRenderController.php index 57a5d62..b3b1b91 100644 --- a/core/modules/block/lib/Drupal/block/BlockRenderController.php +++ b/core/modules/block/lib/Drupal/block/BlockRenderController.php @@ -18,22 +18,22 @@ class BlockRenderController implements EntityRenderControllerInterface { /** * Implements \Drupal\Core\Entity\EntityRenderControllerInterface::buildContent(). */ - public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) { + public function buildContent(array $entities, array $displays, $view_mode) { return array(); } /** * Implements Drupal\Core\Entity\EntityRenderControllerInterface::view(). */ - public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { - $build = $this->viewMultiple(array($entity), $view_mode, $langcode); + public function view(EntityInterface $entity, $view_mode = 'full') { + $build = $this->viewMultiple(array($entity), $view_mode); return reset($build); } /** * Implements Drupal\Core\Entity\EntityRenderControllerInterface::viewMultiple(). */ - public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { + public function viewMultiple(array $entities = array(), $view_mode = 'full') { $build = array(); foreach ($entities as $entity_id => $entity) { $plugin = $entity->getPlugin(); diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php index a613825..c4ee033 100644 --- a/core/modules/comment/comment.api.php +++ b/core/modules/comment/comment.api.php @@ -86,12 +86,10 @@ function hook_comment_load(Drupal\comment\Comment $comments) { * comment components. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode - * The language code used for rendering. * * @see hook_entity_view() */ -function hook_comment_view(\Drupal\comment\Entity\Comment $comment, \Drupal\entity\Entity\EntityDisplay $display, $view_mode, $langcode) { +function hook_comment_view(\Drupal\comment\Entity\Comment $comment, \Drupal\entity\Entity\EntityDisplay $display, $view_mode) { // 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(). diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index b7869fb..7b00ef7 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -850,15 +850,12 @@ function comment_prepare_thread(&$comments) { * The comment object. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode - * (optional) A language code to use for rendering. Defaults to the global - * content language of the current request. * * @return * An array as expected by drupal_render(). */ -function comment_view(Comment $comment, $view_mode = 'full', $langcode = NULL) { - return entity_view($comment, $view_mode, $langcode); +function comment_view(Comment $comment, $view_mode = 'full') { + return entity_view($comment, $view_mode); } /** @@ -942,8 +939,8 @@ function comment_links(Comment $comment, EntityInterface $node) { * * @see drupal_render() */ -function comment_view_multiple($comments, $view_mode = 'full', $langcode = NULL) { - return entity_view_multiple($comments, $view_mode, $langcode); +function comment_view_multiple($comments, $view_mode = 'full') { + return entity_view_multiple($comments, $view_mode); } /** @@ -1213,7 +1210,7 @@ function comment_node_update_index(EntityInterface $node, $langcode) { if ($node->comment && $cids = comment_get_thread($node, $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); comment_prepare_thread($comments); - $build = comment_view_multiple($comments, $langcode); + $build = comment_view_multiple($comments); return drupal_render($build); } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentRenderController.php b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php index 641c566..4fee505 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentRenderController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php @@ -22,7 +22,7 @@ class CommentRenderController extends EntityRenderController { * In addition to modifying the content key on entities, this implementation * will also set the node key which all comments carry. */ - public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) { + public function buildContent(array $entities, array $displays, $view_mode) { $return = array(); if (empty($entities)) { return $return; @@ -35,7 +35,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang } user_load_multiple(array_unique($uids)); - parent::buildContent($entities, $displays, $view_mode, $langcode); + parent::buildContent($entities, $displays, $view_mode); // Load all nodes of all comments at once. $nids = array(); @@ -72,8 +72,8 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang /** * Overrides Drupal\Core\Entity\EntityRenderController::alterBuild(). */ - protected function alterBuild(array &$build, EntityInterface $comment, EntityDisplay $display, $view_mode, $langcode = NULL) { - parent::alterBuild($build, $comment, $display, $view_mode, $langcode); + protected function alterBuild(array &$build, EntityInterface $comment, EntityDisplay $display, $view_mode) { + parent::alterBuild($build, $comment, $display, $view_mode); if (empty($comment->in_preview)) { $prefix = ''; $is_threaded = isset($comment->divs) diff --git a/core/modules/contact/lib/Drupal/contact/MessageRenderController.php b/core/modules/contact/lib/Drupal/contact/MessageRenderController.php index f8aca5d..7f00456 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageRenderController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageRenderController.php @@ -18,8 +18,8 @@ class MessageRenderController extends EntityRenderController { /** * Overrides Drupal\Core\Entity\EntityRenderController::buildContent(). */ - public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) { - parent::buildContent($entities, $displays, $view_mode, $langcode); + public function buildContent(array $entities, array $displays, $view_mode) { + parent::buildContent($entities, $displays, $view_mode); foreach ($entities as $entity) { // Add the message extra field, if enabled. @@ -37,8 +37,8 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang /** * Overrides Drupal\Core\Entity\EntityRenderController::view(). */ - public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { - $build = parent::view($entity, $view_mode, $langcode); + public function view(EntityInterface $entity, $view_mode = 'full') { + $build = parent::view($entity, $view_mode); if ($view_mode == 'mail') { // Convert field labels into headings. diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc index fb97eff..e508728 100644 --- a/core/modules/field/field.deprecated.inc +++ b/core/modules/field/field.deprecated.inc @@ -1067,9 +1067,7 @@ function field_attach_delete_revision(EntityInterface $entity) { * * @deprecated as of Drupal 8.0. Use the entity system instead. */ -function field_attach_prepare_view($entity_type, array $entities, array $displays, $langcode = NULL) { - $options['langcode'] = array(); - +function field_attach_prepare_view($entity_type, array $entities, array $displays) { // To ensure hooks are only run once per entity, only process items without // the _field_view_prepared flag. // @todo: resolve this more generally for both entity and field level hooks. @@ -1082,10 +1080,6 @@ function field_attach_prepare_view($entity_type, array $entities, array $display // Add this entity to the items to be prepared. $prepare[$id] = $entity; - // Determine the actual language code to display for each field, given the - // language codes available in the field data. - $options['langcode'][$id] = field_language($entity, NULL, $langcode); - // Mark this item as prepared. $entity->_field_view_prepared = TRUE; } @@ -1131,12 +1125,9 @@ function field_attach_prepare_view($entity_type, array $entities, array $display * * @deprecated as of Drupal 8.0. Use the entity system instead. */ -function field_attach_view(EntityInterface $entity, EntityDisplay $display, $langcode = NULL, array $options = array()) { +function field_attach_view(EntityInterface $entity, EntityDisplay $display, array $options = array()) { // Ensure we are working with a BC mode entity. $entity = $entity->getBCEntity(); - // Determine the actual language code to display for each field, given the - // language codes available in the field data. - $options['langcode'] = field_language($entity, NULL, $langcode); // For each instance, call the view() method on the formatter object handed // by the entity display. @@ -1154,7 +1145,6 @@ function field_attach_view(EntityInterface $entity, EntityDisplay $display, $lan 'entity' => $entity, 'view_mode' => $view_mode, 'display_options' => $view_mode, - 'langcode' => $langcode, ); drupal_alter('field_attach_view', $output, $context); diff --git a/core/modules/node/lib/Drupal/node/NodeRenderController.php b/core/modules/node/lib/Drupal/node/NodeRenderController.php index 6da0b29..6319d68 100644 --- a/core/modules/node/lib/Drupal/node/NodeRenderController.php +++ b/core/modules/node/lib/Drupal/node/NodeRenderController.php @@ -19,7 +19,7 @@ class NodeRenderController extends EntityRenderController { /** * Overrides Drupal\Core\Entity\EntityRenderController::buildContent(). */ - public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) { + public function buildContent(array $entities, array $displays, $view_mode) { $return = array(); if (empty($entities)) { return $return; @@ -28,7 +28,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang // Attach user account. user_attach_accounts($entities); - parent::buildContent($entities, $displays, $view_mode, $langcode); + parent::buildContent($entities, $displays, $view_mode); foreach ($entities as $entity) { $bundle = $entity->bundle(); @@ -69,7 +69,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang $entity->content['language'] = array( '#type' => 'item', '#title' => t('Language'), - '#markup' => language_name($langcode), + '#markup' => $entity->language()->name, '#prefix' => '