You are here

public function BlazyAdminBase::getViewModeOptions in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::getViewModeOptions()
  2. 8 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::getViewModeOptions()

Returns available view modes for select options.

1 call to BlazyAdminBase::getViewModeOptions()
BlazyAdminBase::baseForm in src/Form/BlazyAdminBase.php
Returns simple form elements common for Views field, EB widget, formatters.

File

src/Form/BlazyAdminBase.php, line 678

Class

BlazyAdminBase
A base for blazy admin integration to have re-usable methods in one place.

Namespace

Drupal\blazy\Form

Code

public function getViewModeOptions($entity_type) {
  if (!isset($this->viewModeOptions)) {
    $this->viewModeOptions = [
      'default' => t('Default'),
    ];
    $view_mode_excludes = [
      'rss',
      'search_index',
      'search_result',
      'print',
      'token',
      'preview',
      'wysiwyg',
    ];
    $entity_info = entity_get_info($entity_type);
    if (!empty($entity_info['view modes'])) {
      foreach ($entity_info['view modes'] as $view_mode => $view_mode_settings) {
        if (in_array($view_mode, $view_mode_excludes)) {
          continue;
        }
        $this->viewModeOptions[$view_mode] = check_plain($view_mode_settings['label']);
      }
    }
  }
  return $this->viewModeOptions;
}