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' => '
', '#suffix' => '
' ); @@ -80,8 +80,8 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang /** * 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); if ($entity->id()) { $build['#contextual_links']['node'] = array('node', array($entity->id())); } diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index a6ec9ef..e657359 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -793,8 +793,6 @@ function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$fo * node components. * @param string $view_mode * The $view_mode parameter from node_view(). - * @param string $langcode - * The language code used for rendering. * * @see forum_node_view() * @see comment_node_view() @@ -802,7 +800,7 @@ function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$fo * * @ingroup node_api_hooks */ -function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\entity\Entity\EntityDisplay $display, $view_mode, $langcode) { +function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \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/node/node.module b/core/modules/node/node.module index 2353be3..2e0a0e2 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -937,15 +937,15 @@ function node_search_execute($keys = NULL, $conditions = NULL) { $results = array(); foreach ($find as $item) { // Render the node. - $node = node_load($item->sid); - $build = node_view($node, 'search_result', $item->langcode); + $node = node_load($item->sid)->getTranslation($item->langcode); + $build = node_view($node, 'search_result'); unset($build['#theme']); $node->rendered = drupal_render($build); // Fetch comments for snippet. - $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->langcode); + $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node); - $extra = Drupal::moduleHandler()->invokeAll('node_search_result', array($node, $item->langcode)); + $extra = Drupal::moduleHandler()->invokeAll('node_search_result', array($node)); $language = language_load($item->langcode); $uri = $node->uri(); @@ -956,7 +956,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) { $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), 'type' => check_plain(node_get_type_label($node)), - 'title' => $node->label($item->langcode), + 'title' => $node->label(), 'user' => drupal_render($username), 'date' => $node->getChangedTime(), 'node' => $node, @@ -1647,15 +1647,12 @@ function node_feed($nids = FALSE, $channel = array()) { * A node entity. * @param $view_mode * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'full.' - * @param $langcode - * (optional) A language code to use for rendering. Defaults to NULL which is - * the global content language of the current request. * * @return * An array as expected by drupal_render(). */ -function node_view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) { - return entity_view($node, $view_mode, $langcode); +function node_view(EntityInterface $node, $view_mode = 'full') { + return entity_view($node, $view_mode); } /** @@ -1665,15 +1662,12 @@ function node_view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) * An array of nodes as returned by node_load_multiple(). * @param $view_mode * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'teaser.' - * @param $langcode - * (optional) A language code to use for rendering. Defaults to the global - * content language of the current request. * * @return * An array in the format expected by drupal_render(). */ -function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) { - return entity_view_multiple($nodes, $view_mode, $langcode); +function node_view_multiple($nodes, $view_mode = 'teaser') { + return entity_view_multiple($nodes, $view_mode); } /** diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index 1fff4a6..33fb355 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -206,7 +206,7 @@ function hook_search_execute($keys = NULL, $conditions = NULL) { foreach ($find as $item) { // Render the node. $node = node_load($item->sid); - $build = node_view($node, 'search_result', $item->langcode); + $build = node_view($node->getTranslation($item->langcode), 'search_result'); unset($build['#theme']); $node->rendered = drupal_render($build); diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestRenderController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestRenderController.php index 0c56533..30ffd68 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestRenderController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestRenderController.php @@ -19,8 +19,8 @@ class EntityTestRenderController 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) { $entity->content['label'] = array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php index cf319d0..8187ff4 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php @@ -19,8 +19,8 @@ class TermRenderController 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 description if enabled. @@ -38,8 +38,8 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang /** * Overrides \Drupal\Core\Entity\EntityRenderController::getBuildDefaults(). */ - protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { - $return = parent::getBuildDefaults($entity, $view_mode, $langcode); + protected function getBuildDefaults(EntityInterface $entity, $view_mode) { + $return = parent::getBuildDefaults($entity, $view_mode); // TODO: rename "term" to "taxonomy_term" in theme_taxonomy_term(). $return['#term'] = $return["#{$this->entityType}"]; @@ -51,8 +51,8 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco /** * 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); $build['#attached']['css'][] = drupal_get_path('module', 'taxonomy') . '/css/taxonomy.module.css'; $build['#contextual_links']['taxonomy'] = array('taxonomy/term', array($entity->id())); } diff --git a/core/modules/taxonomy/taxonomy.api.php b/core/modules/taxonomy/taxonomy.api.php index 44b5c52..ee3a69a 100644 --- a/core/modules/taxonomy/taxonomy.api.php +++ b/core/modules/taxonomy/taxonomy.api.php @@ -255,12 +255,10 @@ function hook_taxonomy_term_delete(Drupal\taxonomy\Term $term) { * term components. * @param $view_mode * The $view_mode parameter from taxonomy_term_view(). - * @param $langcode - * The language code used for rendering. * * @see hook_entity_view() */ -function hook_taxonomy_term_view(\Drupal\taxonomy\Entity\Term $term, \Drupal\entity\Entity\EntityDisplay $display, $view_mode, $langcode) { +function hook_taxonomy_term_view(\Drupal\taxonomy\Entity\Term $term, \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 // vocabulary in hook_field_extra_fields(). diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index f4258cd..8bf2d00 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -397,15 +397,12 @@ function taxonomy_check_vocabulary_hierarchy(VocabularyInterface $vocabulary, $c * A taxonomy term object. * @param string $view_mode * View mode, e.g. 'full', 'teaser'... - * @param string $langcode - * (optional) A language code to use for rendering. Defaults to the global - * content language of the current request. * * @return array * A $page element suitable for use by drupal_page_render(). */ -function taxonomy_term_view(Term $term, $view_mode = 'full', $langcode = NULL) { - return entity_view($term, $view_mode, $langcode); +function taxonomy_term_view(Term $term, $view_mode = 'full') { + return entity_view($term, $view_mode); } /** @@ -415,15 +412,12 @@ function taxonomy_term_view(Term $term, $view_mode = 'full', $langcode = NULL) { * An array of taxonomy terms as returned by entity_load_multiple('taxonomy_term'). * @param string $view_mode * View mode, e.g. 'full', 'teaser'... - * @param string $langcode - * (optional) A language code to use for rendering. Defaults to the global - * content language of the current request. * * @return array * An array in the format expected by drupal_render(). */ -function taxonomy_term_view_multiple(array $terms, $view_mode = 'full', $langcode = NULL) { - return entity_view_multiple($terms, $view_mode, $langcode); +function taxonomy_term_view_multiple(array $terms, $view_mode = 'full') { + return entity_view_multiple($terms, $view_mode); } /** diff --git a/core/modules/tour/lib/Drupal/tour/TourRenderController.php b/core/modules/tour/lib/Drupal/tour/TourRenderController.php index aea0d33..0607dcb 100644 --- a/core/modules/tour/lib/Drupal/tour/TourRenderController.php +++ b/core/modules/tour/lib/Drupal/tour/TourRenderController.php @@ -18,7 +18,7 @@ class TourRenderController extends EntityRenderController { /** * Overrides \Drupal\Core\Entity\EntityRenderController::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) { $tips = $entity->getTips(); diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php index 9d6f73e..192a902 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -319,13 +319,11 @@ function hook_user_logout($account) { * user components. * @param $view_mode * View mode, e.g. 'full'. - * @param $langcode - * The language code used for rendering. * * @see hook_user_view_alter() * @see hook_entity_view() */ -function hook_user_view(\Drupal\user\UserInterface $account, \Drupal\entity\Entity\EntityDisplay $display, $view_mode, $langcode) { +function hook_user_view(\Drupal\user\UserInterface $account, \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 // user entity type in hook_field_extra_fields(). diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 62ccfd6..1f072e6 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1420,15 +1420,12 @@ function user_view_page($account) { * A user object. * @param $view_mode * View mode, e.g. 'full'. - * @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 user_view($account, $view_mode = 'full', $langcode = NULL) { - return entity_view($account, $view_mode, $langcode); +function user_view($account, $view_mode = 'full') { + return entity_view($account, $view_mode); } /** @@ -1438,15 +1435,12 @@ function user_view($account, $view_mode = 'full', $langcode = NULL) { * An array of user accounts as returned by user_load_multiple(). * @param $view_mode * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'teaser.' - * @param $langcode - * (optional) A language code to use for rendering. Defaults to the global - * content language of the current request. * * @return * An array in the format expected by drupal_render(). */ -function user_view_multiple($accounts, $view_mode = 'full', $langcode = NULL) { - return entity_view($accounts, $view_mode, $langcode); +function user_view_multiple($accounts, $view_mode = 'full') { + return entity_view_multiple($accounts, $view_mode); } /**