You are here

protected function EdgeEntityViewBuilder::getBuildDefaults in Apigee Edge 8

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

Overrides EntityViewBuilder::getBuildDefaults

1 call to EdgeEntityViewBuilder::getBuildDefaults()
TeamViewBuilder::getBuildDefaults in modules/apigee_edge_teams/src/Entity/TeamViewBuilder.php
Provides entity-specific defaults to the build process.
1 method overrides EdgeEntityViewBuilder::getBuildDefaults()
TeamViewBuilder::getBuildDefaults in modules/apigee_edge_teams/src/Entity/TeamViewBuilder.php
Provides entity-specific defaults to the build process.

File

src/Entity/EdgeEntityViewBuilder.php, line 34

Class

EdgeEntityViewBuilder
Default view builder class for Apigee Edge entities.

Namespace

Drupal\apigee_edge\Entity

Code

protected function getBuildDefaults(EntityInterface $entity, $view_mode) : array {
  $defaults = parent::getBuildDefaults($entity, $view_mode);

  // Simplified path to the entity.
  $defaults['#entity'] = $entity;

  // Use the generic apigee_entity theme if the entity type specific theme
  // does not exist. Drupal core does not provide a default template for
  // entities yet. This solution also allows to change the default, non-entity
  // type specific theme that is being used if the entity type specific does
  // not exist.
  // When 2808481 gets in core, the default theme becomes the "entity".
  // Because of BC we can not use that.
  // @see apigee-entity.html.twig
  // @see https://www.drupal.org/project/drupal/issues/2808481
  if (!isset($defaults['#theme']) || $defaults['#theme'] === 'entity') {
    $defaults['#theme'] = 'apigee_entity';
  }
  return $defaults;
}