function entity_get_view_modes

Returns the entity view mode info.

Parameters

string|null $entity_type: The entity type whose view mode info should be returned, or NULL for all view mode info. Defaults to NULL.

Return value

array The view mode info for a specific entity type, or all entity types.

15 calls to entity_get_view_modes()
CustomBlockBlock::blockForm in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php
Overrides \Drupal\block\BlockBase::blockForm().
DisplayOverview::buildForm in drupal/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
Implements \Drupal\Core\Form\FormInterface::buildForm().
DisplayOverview::submitForm in drupal/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
Overrides \Drupal\field_ui\OverviewBase::submitForm().
Entity::buildViewModeOptions in drupal/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php
Return the main options, which are shown in the summary title.
EntityReferenceEntityFormatter::settingsForm in drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/formatter/EntityReferenceEntityFormatter.php
Returns a form to configure settings for the formatter.

... See full list

1 string reference to 'entity_get_view_modes'
entity_info_cache_clear in drupal/core/includes/entity.inc
Resets the cached information about entity types.

File

drupal/core/includes/entity.inc, line 117
Entity API for handling entities like nodes or users.

Code

function entity_get_view_modes($entity_type = NULL) {
  $view_modes =& drupal_static(__FUNCTION__);
  if (!$view_modes) {
    $langcode = language(Language::TYPE_INTERFACE)->langcode;
    if ($cache = cache()
      ->get("entity_view_mode_info:{$langcode}")) {
      $view_modes = $cache->data;
    }
    else {
      $view_modes = array();
      foreach (entity_load_multiple('view_mode') as $view_mode) {
        list($view_mode_entity_type, $view_mode_name) = explode('.', $view_mode
          ->id(), 2);
        $view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode;
      }
      drupal_alter('entity_view_mode_info', $view_modes);
      cache()
        ->set("entity_view_mode_info:{$langcode}", $view_modes, CacheBackendInterface::CACHE_PERMANENT, array(
        'entity_info' => TRUE,
      ));
    }
  }
  if (empty($entity_type)) {
    return $view_modes;
  }
  elseif (isset($view_modes[$entity_type])) {
    return $view_modes[$entity_type];
  }
  return array();
}