Commit ace96deb authored by effulgentsia's avatar effulgentsia

Issue #2073217 by andypost, Berdir, plach: Remove the $langcode parameter from...

Issue #2073217 by andypost, Berdir, plach: Remove the $langcode parameter from the entity view/render system
parent bfb117c5
......@@ -360,7 +360,7 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) {
function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) {
$render_controller = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId());
if ($reset) {
$render_controller->resetCache(array($entity->id()));
$render_controller->resetCache([$entity]);
}
return $render_controller->view($entity, $view_mode, $langcode);
}
......@@ -397,7 +397,7 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) {
$render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->getEntityTypeId());
if ($reset) {
$render_controller->resetCache(array_keys($entities));
$render_controller->resetCache($entities);
}
return $render_controller->viewMultiple($entities, $view_mode, $langcode);
}
......
......@@ -91,17 +91,14 @@ public function buildTitle(array $page) {
* @param string $view_mode
* (optional) The view mode that should be used to display the entity.
* Defaults to 'full'.
* @param string $langcode
* (optional) For which language the entity should be rendered, defaults to
* the current content language.
*
* @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') {
$page = $this->entityManager
->getViewBuilder($_entity->getEntityTypeId())
->view($_entity, $view_mode, $langcode);
->view($_entity, $view_mode);
$page['#pre_render'][] = [$this, 'buildTitle'];
$page['#entity_type'] = $_entity->getEntityTypeId();
......
......@@ -12,10 +12,9 @@
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\TypedData\TranslatableInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\TypedData\TranslatableInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -120,7 +119,6 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
$build_list = array(
'#sorted' => TRUE,
'#pre_render' => array(array($this, 'buildMultiple')),
'#langcode' => $langcode ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(),
);
$weight = 0;
foreach ($entities as $key => $entity) {
......@@ -129,10 +127,9 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
$entity = $this->entityManager->getTranslationFromContext($entity, $langcode);
// Set build defaults.
$entity_langcode = $entity->language()->getId();
$build_list[$key] = $this->getBuildDefaults($entity, $view_mode, $entity_langcode);
$build_list[$key] = $this->getBuildDefaults($entity, $view_mode);
$entityType = $this->entityTypeId;
$this->moduleHandler()->alter(array($entityType . '_build_defaults', 'entity_build_defaults'), $build_list[$key], $entity, $view_mode, $entity_langcode);
$this->moduleHandler()->alter(array($entityType . '_build_defaults', 'entity_build_defaults'), $build_list[$key], $entity, $view_mode);
$build_list[$key]['#weight'] = $weight++;
}
......@@ -147,22 +144,18 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
* The entity for which the defaults should be provided.
* @param string $view_mode
* The view mode that should be used.
* @param string $langcode
* 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) {
// Allow modules to change the view mode.
$context = array('langcode' => $langcode);
$context = [];
$this->moduleHandler()->alter('entity_view_mode', $view_mode, $entity, $context);
$build = array(
'#theme' => $this->entityTypeId,
"#{$this->entityTypeId}" => $entity,
'#view_mode' => $view_mode,
'#langcode' => $langcode,
// Collect cache defaults for this entity.
'#cache' => array(
'tags' => Cache::mergeTags($this->getCacheTags(), $entity->getCacheTags()),
......@@ -185,7 +178,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
);
if ($entity instanceof TranslatableInterface && count($entity->getTranslationLanguages()) > 1) {
$build['#cache']['keys'][] = $langcode;
$build['#cache']['keys'][] = $entity->language()->getId();
}
}
......@@ -211,10 +204,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
* @see drupal_render()
*/
public function build(array $build) {
$build_list = array(
'#langcode' => $build['#langcode'],
);
$build_list[] = $build;
$build_list = [$build];
$build_list = $this->buildMultiple($build_list);
return $build_list[0];
}
......@@ -240,7 +230,6 @@ public function build(array $build) {
public function buildMultiple(array $build_list) {
// Build the view modes and display objects.
$view_modes = array();
$langcode = $build_list['#langcode'];
$entity_type_key = "#{$this->entityTypeId}";
$view_hook = "{$this->entityTypeId}_view";
......@@ -259,16 +248,16 @@ public function buildMultiple(array $build_list) {
// Build content for the displays represented by the entities.
foreach ($view_modes as $view_mode => $view_mode_entities) {
$displays = EntityViewDisplay::collectRenderDisplays($view_mode_entities, $view_mode);
$this->buildComponents($build_list, $view_mode_entities, $displays, $view_mode, $langcode);
$this->buildComponents($build_list, $view_mode_entities, $displays, $view_mode);
foreach (array_keys($view_mode_entities) as $key) {
// Allow for alterations while building, before rendering.
$entity = $build_list[$key][$entity_type_key];
$display = $displays[$entity->bundle()];
$this->moduleHandler()->invokeAll($view_hook, array(&$build_list[$key], $entity, $display, $view_mode, $langcode));
$this->moduleHandler()->invokeAll('entity_view', array(&$build_list[$key], $entity, $display, $view_mode, $langcode));
$this->moduleHandler()->invokeAll($view_hook, [&$build_list[$key], $entity, $display, $view_mode]);
$this->moduleHandler()->invokeAll('entity_view', [&$build_list[$key], $entity, $display, $view_mode]);
$this->alterBuild($build_list[$key], $entity, $display, $view_mode, $langcode);
$this->alterBuild($build_list[$key], $entity, $display, $view_mode);
// Assign the weights configured in the display.
// @todo: Once https://www.drupal.org/node/1875974 provides the missing
......@@ -291,7 +280,7 @@ public function buildMultiple(array $build_list) {
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
$entities_by_bundle = array();
foreach ($entities as $id => $entity) {
// Initialize the field item attributes for the fields being displayed.
......@@ -335,11 +324,8 @@ public function buildComponents(array &$build, array $entities, array $displays,
* 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, EntityViewDisplayInterface $display, $view_mode, $langcode = NULL) { }
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { }
/**
* {@inheritdoc}
......
......@@ -29,11 +29,8 @@ interface EntityViewBuilderInterface {
* 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.
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL);
public function buildComponents(array &$build, array $entities, array $displays, $view_mode);
/**
* Builds the render array for the provided entity.
......
......@@ -468,7 +468,9 @@
* @endcode
* Then, to build and render the entity:
* @code
* // You can omit the language ID if the default language is being used.
* // You can omit the language ID, by default the current content language will
* // be used. If no translation is available for the current language, fallback
* // rules will be used.
* $build = $view_builder->view($entity, 'view_mode_name', $language->getId());
* // $build is a render array.
* $rendered = drupal_render($build);
......@@ -502,6 +504,7 @@
*
* @see i18n
* @see entity_crud
* @see \Drupal\Core\Entity\EntityManagerInterface::getTranslationFromContext()
* @}
*/
......@@ -1232,8 +1235,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 $build prior to rendering. The
* structure of $build is a renderable array as expected by
......@@ -1244,7 +1245,7 @@ function hook_entity_query_alter(\Drupal\Core\Entity\Query\QueryInterface $query
*
* @ingroup entity_crud
*/
function hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode, $langcode) {
function hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $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_entity_extra_field_info().
......@@ -1268,8 +1269,6 @@ function hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $en
* 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 $build prior to rendering. The
* structure of $build is a renderable array as expected by
......@@ -1280,7 +1279,7 @@ function hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $en
*
* @ingroup entity_crud
*/
function hook_ENTITY_TYPE_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode, $langcode) {
function hook_ENTITY_TYPE_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $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_entity_extra_field_info().
......@@ -1443,8 +1442,6 @@ function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInter
* The entity that is being viewed.
* @param string $view_mode
* The view_mode that is to be used to display the entity.
* @param string $langcode
* The code of the language $entity is accessed in.
*
* @see drupal_render()
* @see \Drupal\Core\Entity\EntityViewBuilder
......@@ -1452,7 +1449,7 @@ function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInter
*
* @ingroup entity_crud
*/
function hook_ENTITY_TYPE_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode, $langcode) {
function hook_ENTITY_TYPE_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode) {
}
......@@ -1469,8 +1466,6 @@ function hook_ENTITY_TYPE_build_defaults_alter(array &$build, \Drupal\Core\Entit
* The entity that is being viewed.
* @param string $view_mode
* The view_mode that is to be used to display the entity.
* @param string $langcode
* The code of the language $entity is accessed in.
*
* @see drupal_render()
* @see \Drupal\Core\Entity\EntityViewBuilder
......@@ -1478,7 +1473,7 @@ function hook_ENTITY_TYPE_build_defaults_alter(array &$build, \Drupal\Core\Entit
*
* @ingroup entity_crud
*/
function hook_entity_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode, $langcode) {
function hook_entity_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode) {
}
......
......@@ -52,8 +52,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
$bundle = $entity->bundle();
......@@ -69,7 +69,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
$build[$id]['items'] = $this->entityManager
->getViewBuilder('aggregator_item')
->viewMultiple($items, $view_mode, $langcode);
->viewMultiple($items, $view_mode, $entity->language()->getId());
if ($view_mode == 'full') {
// Also add the pager.
......
......@@ -17,8 +17,8 @@ class ItemViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
$bundle = $entity->bundle();
......
......@@ -65,7 +65,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
}
/**
......@@ -192,7 +192,7 @@ protected static function buildPreRenderableBlock($entity, ModuleHandlerInterfac
* @return array
* A render array with a #pre_render callback to render the block.
*/
public static function lazyBuilder($entity_id, $view_mode, $langcode) {
public static function lazyBuilder($entity_id, $view_mode) {
return static::buildPreRenderableBlock(entity_load('block', $entity_id), \Drupal::service('module_handler'));
}
......
......@@ -38,8 +38,8 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
/**
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$build = parent::getBuildDefaults($entity, $view_mode, $langcode);
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
$build = parent::getBuildDefaults($entity, $view_mode);
// The custom block will be rendered in the wrapped block template already
// and thus has no entity template itself.
unset($build['#theme']);
......@@ -49,8 +49,8 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
/**
* {@inheritdoc}
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $entity, $display, $view_mode, $langcode);
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
parent::alterBuild($build, $entity, $display, $view_mode);
// Add contextual links for this custom block.
if (!$entity->isNew()) {
$build['#contextual_links']['block_content'] = array(
......
......@@ -215,7 +215,7 @@ function comment_node_links_alter(array &$node_links, NodeInterface $node, array
/**
* Implements hook_entity_view().
*/
function comment_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode, $langcode) {
function comment_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($entity instanceof FieldableEntityInterface && $view_mode == 'rss' && $display->getComponent('links')) {
/** @var \Drupal\comment\CommentManagerInterface $comment_manager */
$comment_manager = \Drupal::service('comment.manager');
......@@ -426,7 +426,7 @@ function _comment_entity_uses_integer_id($entity_type_id) {
/**
* Implements hook_node_update_index().
*/
function comment_node_update_index(EntityInterface $node, $langcode) {
function comment_node_update_index(EntityInterface $node) {
$index_comments = &drupal_static(__FUNCTION__);
if ($index_comments === NULL) {
......
......@@ -62,8 +62,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
/**
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$build = parent::getBuildDefaults($entity, $view_mode, $langcode);
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
$build = parent::getBuildDefaults($entity, $view_mode);
/** @var \Drupal\comment\CommentInterface $entity */
// Store a threading field setting to use later in self::buildComponents().
......@@ -88,7 +88,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
* @throws \InvalidArgumentException
* Thrown when a comment is attached to an entity that no longer exists.
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
/** @var \Drupal\comment\CommentInterface[] $entities */
if (empty($entities)) {
return;
......@@ -101,7 +101,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
}
$this->entityManager->getStorage('user')->loadMultiple(array_unique($uids));
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
parent::buildComponents($build, $entities, $displays, $view_mode);
// A counter to track the indentation level.
$current_indent = 0;
......@@ -136,7 +136,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
'#lazy_builder' => ['comment.lazy_builders:renderLinks', [
$entity->id(),
$view_mode,
$langcode,
$entity->language()->getId(),
!empty($entity->in_preview),
]],
'#create_placeholder' => TRUE,
......@@ -166,8 +166,8 @@ public function buildComponents(array &$build, array $entities, array $displays,
/**
* {@inheritdoc}
*/
protected function alterBuild(array &$build, EntityInterface $comment, EntityViewDisplayInterface $display, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $comment, $display, $view_mode, $langcode);
protected function alterBuild(array &$build, EntityInterface $comment, EntityViewDisplayInterface $display, $view_mode) {
parent::alterBuild($build, $comment, $display, $view_mode);
if (empty($comment->in_preview)) {
$prefix = '';
......
......@@ -142,7 +142,7 @@ function contact_mail($key, &$message, $params) {
case 'page_copy':
$message['subject'] .= t('[@form] @subject', $variables, $options);
$message['body'][] = t("@sender-name (@sender-url) sent a message using the contact form at @form-url.", $variables, $options);
$build = entity_view($contact_message, 'mail', $language->getId());
$build = entity_view($contact_message, 'mail');
$message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build);
break;
......@@ -161,7 +161,7 @@ function contact_mail($key, &$message, $params) {
$message['body'][] = t('Hello @recipient-name,', $variables, $options);
$message['body'][] = t("@sender-name (@sender-url) has sent you a message via your contact form at @site-name.", $variables, $options);
$message['body'][] = t("If you don't want to receive such emails, you can change your settings at @recipient-edit-url.", $variables, $options);
$build = entity_view($contact_message, 'mail', $language->getId());
$build = entity_view($contact_message, 'mail');
$message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build);
break;
}
......
......@@ -20,8 +20,8 @@ class MessageViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$build = parent::getBuildDefaults($entity, $view_mode, $langcode);
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
$build = parent::getBuildDefaults($entity, $view_mode);
// The message fields are individually rendered into email templates, so
// the entity has no template itself.
unset($build['#theme']);
......@@ -31,8 +31,8 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
// Add the message extra field, if enabled.
......
......@@ -364,8 +364,6 @@ function hook_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
*
* @param \Drupal\node\NodeInterface $node
* The node being displayed in a search result.
* @param string $langcode
* Language code of result being displayed.
*
* @return array
* Extra information to be displayed with search result. This information
......@@ -378,7 +376,7 @@ function hook_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
*
* @ingroup entity_crud
*/
function hook_node_search_result(\Drupal\node\NodeInterface $node, $langcode) {
function hook_node_search_result(\Drupal\node\NodeInterface $node) {
$rating = db_query('SELECT SUM(points) FROM {my_rating} WHERE nid = :nid', array('nid' => $node->id()))->fetchField();
return array('rating' => \Drupal::translation()->formatPlural($rating, '1 point', '@count points'));
}
......@@ -391,15 +389,13 @@ function hook_node_search_result(\Drupal\node\NodeInterface $node, $langcode) {
*
* @param \Drupal\node\NodeInterface $node
* The node being indexed.
* @param string $langcode
* Language code of the variant of the node being indexed.
*
* @return string
* Additional node information to be indexed.
*
* @ingroup entity_crud
*/
function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) {
function hook_node_update_index(\Drupal\node\NodeInterface $node) {
$text = '';
$ratings = db_query('SELECT title, description FROM {my_ratings} WHERE nid = :nid', array(':nid' => $node->id()));
foreach ($ratings as $rating) {
......
......@@ -21,13 +21,13 @@ class NodeViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
/** @var \Drupal\node\NodeInterface[] $entities */
if (empty($entities)) {
return;
}
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
$bundle = $entity->bundle();
......@@ -38,7 +38,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
'#lazy_builder' => [get_called_class() . '::renderLinks', [
$entity->id(),
$view_mode,
$langcode,
$entity->language()->getId(),
!empty($entity->in_preview),
]],
);
......@@ -60,8 +60,8 @@ public function buildComponents(array &$build, array $entities, array $displays,
/**
* {@inheritdoc}
*/
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);
// Don't cache nodes that are in 'preview' mode.
if (isset($defaults['#cache']) && isset($entity->in_preview)) {
......@@ -148,9 +148,9 @@ protected static function buildLinks(NodeInterface $entity, $view_mode) {
/**
* {@inheritdoc}
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode, $langcode = NULL) {
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
/** @var \Drupal\node\NodeInterface $entity */
parent::alterBuild($build, $entity, $display, $view_mode, $langcode);
parent::alterBuild($build, $entity, $display, $view_mode);
if ($entity->id()) {
$build['#contextual_links']['node'] = array(
'route_parameters' =>array('node' => $entity->id()),
......
......@@ -337,9 +337,9 @@ protected function prepareResults(StatementInterface $found) {
// Fetch comments for snippet.
$rendered = $this->renderer->renderPlain($build);
$this->addCacheableDependency(CacheableMetadata::createFromRenderArray($build));
$rendered .= ' ' . $this->moduleHandler->invoke('comment', 'node_update_index', array($node, $item->langcode));
$rendered .= ' ' . $this->moduleHandler->invoke('comment', 'node_update_index', [$node]);
$extra = $this->moduleHandler->invokeAll('node_search_result', array($node, $item->langcode));
$extra = $this->moduleHandler->invokeAll('node_search_result', [$node]);
$language = $this->languageManager->getLanguage($item->langcode);
$username = array(
......@@ -461,14 +461,14 @@ protected function indexNode(NodeInterface $node) {
// Add the title to text so it is searchable.
$build['search_title'] = [
'#prefix' => '<h1>',
'#plain_text' => $node->label($language->getId()),
'#plain_text' => $node->label(),
'#suffix' => '</h1>',
'#weight' => -1000
];
$text = $this->renderer->renderPlain($build);
// Fetch extra data normally not visible.
$extra = $this->moduleHandler->invokeAll('node_update_index', array($node, $language->getId()));
$extra = $this->moduleHandler->invokeAll('node_update_index', [$node]);
foreach ($extra as $t) {
$text .= $t;
}
......
......@@ -41,7 +41,7 @@ function node_test_node_view(array &$build, NodeInterface $node, EntityViewDispl
/**
* Implements hook_ENTITY_TYPE_build_defaults_alter() for node entities.
*/
function node_test_node_build_defaults_alter(array &$build, NodeInterface &$node, $view_mode = 'full', $langcode = NULL) {
function node_test_node_build_defaults_alter(array &$build, NodeInterface &$node, $view_mode = 'full') {
if ($view_mode == 'rss') {
$node->rss_namespaces['xmlns:drupaltest'] = 'http://example.com/test-namespace';
}
......
......@@ -20,8 +20,8 @@ class EntityTestViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$build = parent::getBuildDefaults($entity, $view_mode, $langcode);
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
$build = parent::getBuildDefaults($entity, $view_mode);
unset($build['#theme']);
return $build;
}
......@@ -29,8 +29,8 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
$build[$id]['label'] = array(
......
......@@ -19,8 +19,8 @@ class TermViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $entity, $display, $view_mode, $langcode);
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
parent::alterBuild($build, $entity, $display, $view_mode);
$build['#contextual_links']['taxonomy_term'] = array(
'route_parameters' => array('taxonomy_term' => $entity->id()),
'metadata' => array('changed' => $entity->getChangedTime()),
......
......@@ -41,7 +41,7 @@ public function __construct(DataDefinitionInterface $definition, $name = NULL, T
/**
* Implements \Drupal\Core\TypedData\TypedDataInterface::getValue().
*/
public function getValue($langcode = NULL) {
public function getValue() {
if ($this->processed !== NULL) {
return $this->processed;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment