You are here

protected function EntityDisplayRepository::getDisplayModeOptions in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityDisplayRepository.php \Drupal\Core\Entity\EntityDisplayRepository::getDisplayModeOptions()

Gets an array of display mode options.

Parameters

string $display_type: The display type to be retrieved. It can be "view_mode" or "form_mode".

string $entity_type_id: The entity type whose display mode options should be returned.

Return value

array An array of display mode labels, keyed by the display mode ID.

3 calls to EntityDisplayRepository::getDisplayModeOptions()
EntityDisplayRepository::getDisplayModeOptionsByBundle in core/lib/Drupal/Core/Entity/EntityDisplayRepository.php
Returns an array of enabled display mode options by bundle.
EntityDisplayRepository::getFormModeOptions in core/lib/Drupal/Core/Entity/EntityDisplayRepository.php
Gets an array of form mode options.
EntityDisplayRepository::getViewModeOptions in core/lib/Drupal/Core/Entity/EntityDisplayRepository.php
Gets an array of view mode options.

File

core/lib/Drupal/Core/Entity/EntityDisplayRepository.php, line 189

Class

EntityDisplayRepository
Provides a repository for entity display objects (view modes and form modes).

Namespace

Drupal\Core\Entity

Code

protected function getDisplayModeOptions($display_type, $entity_type_id) {
  $options = [
    'default' => t('Default'),
  ];
  foreach ($this
    ->getDisplayModesByEntityType($display_type, $entity_type_id) as $mode => $settings) {
    $options[$mode] = $settings['label'];
  }
  return $options;
}