protected function EntityViewBuilder::getBuildDefaults in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/EntityViewBuilder.php \Drupal\Core\Entity\EntityViewBuilder::getBuildDefaults()
Provides entity-specific defaults to the build process.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for which the defaults should be provided.
string $view_mode: The view mode that should be used.
Return value
array
6 calls to EntityViewBuilder::getBuildDefaults()
- BlockContentViewBuilder::getBuildDefaults in core/
modules/ block_content/ src/ BlockContentViewBuilder.php - Provides entity-specific defaults to the build process.
- CommentViewBuilder::getBuildDefaults in core/
modules/ comment/ src/ CommentViewBuilder.php - Provides entity-specific defaults to the build process.
- EntityTestViewBuilder::getBuildDefaults in core/
modules/ system/ tests/ modules/ entity_test/ src/ EntityTestViewBuilder.php - Provides entity-specific defaults to the build process.
- EntityViewBuilder::viewMultiple in core/
lib/ Drupal/ Core/ Entity/ EntityViewBuilder.php - Builds the render array for the provided entities.
- MessageViewBuilder::getBuildDefaults in core/
modules/ contact/ src/ MessageViewBuilder.php - Provides entity-specific defaults to the build process.
5 methods override EntityViewBuilder::getBuildDefaults()
- BlockContentViewBuilder::getBuildDefaults in core/
modules/ block_content/ src/ BlockContentViewBuilder.php - Provides entity-specific defaults to the build process.
- CommentViewBuilder::getBuildDefaults in core/
modules/ comment/ src/ CommentViewBuilder.php - Provides entity-specific defaults to the build process.
- EntityTestViewBuilder::getBuildDefaults in core/
modules/ system/ tests/ modules/ entity_test/ src/ EntityTestViewBuilder.php - Provides entity-specific defaults to the build process.
- MessageViewBuilder::getBuildDefaults in core/
modules/ contact/ src/ MessageViewBuilder.php - Provides entity-specific defaults to the build process.
- NodeViewBuilder::getBuildDefaults in core/
modules/ node/ src/ NodeViewBuilder.php - Provides entity-specific defaults to the build process.
File
- core/
lib/ Drupal/ Core/ Entity/ EntityViewBuilder.php, line 150 - Contains \Drupal\Core\Entity\EntityViewBuilder.
Class
- EntityViewBuilder
- Base class for entity view builders.
Namespace
Drupal\Core\EntityCode
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
// Allow modules to change the view mode.
$context = [];
$this
->moduleHandler()
->alter('entity_view_mode', $view_mode, $entity, $context);
$build = array(
'#theme' => $this->entityTypeId,
"#{$this->entityTypeId}" => $entity,
'#view_mode' => $view_mode,
// Collect cache defaults for this entity.
'#cache' => array(
'tags' => Cache::mergeTags($this
->getCacheTags(), $entity
->getCacheTags()),
'contexts' => $entity
->getCacheContexts(),
'max-age' => $entity
->getCacheMaxAge(),
),
);
// Cache the rendered output if permitted by the view mode and global entity
// type configuration.
if ($this
->isViewModeCacheable($view_mode) && !$entity
->isNew() && $entity
->isDefaultRevision() && $this->entityType
->isRenderCacheable()) {
$build['#cache'] += array(
'keys' => array(
'entity_view',
$this->entityTypeId,
$entity
->id(),
$view_mode,
),
'bin' => $this->cacheBin,
);
if ($entity instanceof TranslatableInterface && count($entity
->getTranslationLanguages()) > 1) {
$build['#cache']['keys'][] = $entity
->language()
->getId();
}
}
return $build;
}