You are here

function token_get_token_view_display in Token 8

Returns the token view display for the given entity if enabled.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

\Drupal\Core\Entity\Display\EntityViewDisplayInterface|null The view display or null.

1 call to token_get_token_view_display()
field_tokens in ./token.tokens.inc
Implements hook_tokens() on behalf of field.module.

File

./token.tokens.inc, line 1923
Token callbacks for the token module.

Code

function token_get_token_view_display(EntityInterface $entity) {
  $view_mode_name = $entity
    ->getEntityTypeId() . '.' . $entity
    ->bundle() . '.token';
  $view_display = \Drupal::entityTypeManager()
    ->getStorage('entity_view_display')
    ->load($view_mode_name);
  return $view_display && $view_display
    ->status() ? $view_display : NULL;
}