Commit 02f761ba authored by alexpott's avatar alexpott

Issue #2154711 by plopesc, tim.plunkett, olli, Berdir, Dave Reid: Move...

Issue #2154711 by plopesc, tim.plunkett, olli, Berdir, Dave Reid: Move entity_get_(form/view)_mode_options() functions to EntityManager and add get(Form/View)ModeOptions() methods.
parent 5909b03b
......@@ -14,7 +14,6 @@
* Resets the cached information about entity types.
*/
function entity_info_cache_clear() {
drupal_static_reset('entity_get_view_modes');
// Clear all languages.
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::entityManager()->clearCachedFieldDefinitions();
......@@ -83,77 +82,45 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N
/**
* Returns the entity form mode info.
*
* @param string|null $entity_type
* @param string|null $entity_type_id
* The entity type whose form mode info should be returned, or NULL for all
* form mode info. Defaults to NULL.
*
* @return array
* The form mode info for a specific entity type, or all entity types.
*
* @deprecated Use \Drupal::entityManager()->getFormModes() or
* \Drupal::entityManager()->getAllFormModes().
*/
function entity_get_form_modes($entity_type = NULL) {
$form_modes = &drupal_static(__FUNCTION__);
if (!$form_modes) {
$langcode = \Drupal::languageManager()->getCurrentLanguage()->id;
if ($cache = \Drupal::cache()->get("entity_form_mode_info:$langcode")) {
$form_modes = $cache->data;
}
else {
$form_modes = array();
foreach (entity_load_multiple('form_mode') as $form_mode) {
list($form_mode_entity_type, $form_mode_name) = explode('.', $form_mode->id(), 2);
$form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode;
}
\Drupal::moduleHandler()->alter('entity_form_mode_info', $form_modes);
\Drupal::cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_types' => TRUE));
}
function entity_get_form_modes($entity_type_id = NULL) {
if (isset($entity_type_id)) {
return \Drupal::entityManager()->getFormModes($entity_type_id);
}
if (empty($entity_type)) {
return $form_modes;
}
elseif (isset($form_modes[$entity_type])) {
return $form_modes[$entity_type];
else {
return \Drupal::entityManager()->getAllFormModes();
}
return array();
}
/**
* Returns the entity view mode info.
*
* @param string|null $entity_type
* @param string|null $entity_type_id
* The entity type whose view mode info should be returned, or NULL for all
* view mode info. Defaults to NULL.
*
* @return array
* The view mode info for a specific entity type, or all entity types.
*
* @deprecated Use \Drupal::entityManager()->getViewModes() or
* \Drupal::entityManager()->getAllViewModes().
*/
function entity_get_view_modes($entity_type = NULL) {
$view_modes = &drupal_static(__FUNCTION__);
if (!$view_modes) {
$langcode = \Drupal::languageManager()->getCurrentLanguage()->id;
if ($cache = \Drupal::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::moduleHandler()->alter('entity_view_mode_info', $view_modes);
\Drupal::cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_types' => TRUE));
}
function entity_get_view_modes($entity_type_id = NULL) {
if (isset($entity_type_id)) {
return \Drupal::entityManager()->getViewModes($entity_type_id);
}
if (empty($entity_type)) {
return $view_modes;
}
elseif (isset($view_modes[$entity_type])) {
return $view_modes[$entity_type];
else {
return \Drupal::entityManager()->getAllViewModes();
}
return array();
}
/**
......
......@@ -114,6 +114,13 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface
*/
protected $bundleInfo;
/**
* Static cache of display modes information.
*
* @var array
*/
protected $displayModeInfo = array();
/**
* Constructs a new Entity plugin manager.
*
......@@ -155,6 +162,7 @@ public function clearCachedDefinitions() {
parent::clearCachedDefinitions();
$this->bundleInfo = NULL;
$this->displayModeInfo = array();
}
/**
......@@ -509,4 +517,123 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N
return $translation;
}
/**
* {@inheritdoc}
*/
public function getAllViewModes() {
return $this->getAllDisplayModesByEntityType('view_mode');
}
/**
* {@inheritdoc}
*/
public function getViewModes($entity_type_id) {
return $this->getDisplayModesByEntityType('view_mode', $entity_type_id);
}
/**
* {@inheritdoc}
*/
public function getAllFormModes() {
return $this->getAllDisplayModesByEntityType('form_mode');
}
/**
* {@inheritdoc}
*/
public function getFormModes($entity_type_id) {
return $this->getDisplayModesByEntityType('form_mode', $entity_type_id);
}
/**
* Returns the entity display mode info for all entity types.
*
* @param string $display_type
* The display type to be retrieved. It can be "view_mode" or "form_mode".
*
* @return array
* The display mode info for all entity types.
*/
protected function getAllDisplayModesByEntityType($display_type) {
if (!isset($this->displayModeInfo[$display_type])) {
$key = 'entity_' . $display_type . '_info';
$langcode = $this->languageManager->getCurrentLanguage(Language::TYPE_INTERFACE)->id;
if ($cache = $this->cache->get("$key:$langcode")) {
$this->displayModeInfo[$display_type] = $cache->data;
}
else {
$this->displayModeInfo[$display_type] = array();
foreach ($this->getStorageController($display_type)->loadMultiple() as $display_mode) {
list($display_mode_entity_type, $display_mode_name) = explode('.', $display_mode->id(), 2);
$this->displayModeInfo[$display_type][$display_mode_entity_type][$display_mode_name] = (array) $display_mode;
}
$this->moduleHandler->alter($key, $this->displayModeInfo[$display_type]);
$this->cache->set("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, array('entity_types' => TRUE));
}
}
return $this->displayModeInfo[$display_type];
}
/**
* Returns the entity display mode info for a specific entity type.
*
* @param string $display_type
* The display type to be retrieved. It can be "view_mode" or "form_mode".
* @param string $entity_type_id
* The entity type whose display mode info should be returned.
*
* @return array
* The display mode info for a specific entity type.
*/
protected function getDisplayModesByEntityType($display_type, $entity_type_id) {
if (isset($this->displayModeInfo[$display_type][$entity_type_id])) {
return $this->displayModeInfo[$display_type][$entity_type_id];
}
else {
$display_modes = $this->getAllDisplayModesByEntityType($display_type);
if (isset($display_modes[$entity_type_id])) {
return $display_modes[$entity_type_id];
}
}
return array();
}
/**
* {@inheritdoc}
*/
public function getViewModeOptions($entity_type, $include_disabled = FALSE) {
return $this->getDisplayModeOptions('view_mode', $entity_type, $include_disabled);
}
/**
* {@inheritdoc}
*/
public function getFormModeOptions($entity_type, $include_disabled = FALSE) {
return $this->getDisplayModeOptions('form_mode', $entity_type, $include_disabled);
}
/**
* Returns an array of display mode options.
*
* @param string $display_type
* The display type to be retrieved. It can be "view_mode" or "form_mode".
* @param string $entity_type_id
* The entity type whose display mode options should be returned.
* @param bool $include_disabled
* Force to include disabled display modes. Defaults to FALSE.
*
* @return array
* An array of display mode labels, keyed by the display mode ID.
*/
protected function getDisplayModeOptions($display_type, $entity_type_id, $include_disabled = FALSE) {
$options = array('default' => t('Default'));
foreach ($this->getDisplayModesByEntityType($display_type, $entity_type_id) as $mode => $settings) {
if (!empty($settings['status']) || $include_disabled) {
$options[$mode] = $settings['label'];
}
}
return $options;
}
}
......@@ -235,4 +235,68 @@ public function getDefinition($entity_type_id, $exception_on_invalid = FALSE);
*/
public function getDefinitions();
/**
* Returns the entity view mode info for all entity types.
*
* @return array
* The view mode info for all entity types.
*/
public function getAllViewModes();
/**
* Returns the entity view mode info for a specific entity type.
*
* @param string $entity_type_id
* The entity type whose view mode info should be returned.
*
* @return array
* The view mode info for a specific entity type.
*/
public function getViewModes($entity_type_id);
/**
* Returns the entity form mode info for all entity types.
*
* @return array
* The form mode info for all entity types.
*/
public function getAllFormModes();
/**
* Returns the entity form mode info for a specific entity type.
*
* @param string $entity_type_id
* The entity type whose form mode info should be returned.
*
* @return array
* The form mode info for a specific entity type.
*/
public function getFormModes($entity_type_id);
/**
* Returns an array of view mode options.
*
* @param string $entity_type_id
* The entity type whose view mode options should be returned.
* @param bool $include_disabled
* Force to include disabled view modes. Defaults to FALSE.
*
* @return array
* An array of view mode labels, keyed by the display mode ID.
*/
public function getViewModeOptions($entity_type_id, $include_disabled = FALSE);
/**
* Returns an array of form mode options.
*
* @param string $entity_type_id
* The entity type whose form mode options should be returned.
* @param bool $include_disabled
* Force to include disabled form modes. Defaults to FALSE.
*
* @return array
* An array of form mode labels, keyed by the display mode ID.
*/
public function getFormModeOptions($entity_type_id, $include_disabled = FALSE);
}
......@@ -362,7 +362,7 @@ protected function isViewModeCacheable($view_mode) {
// The 'default' is not an actual view mode.
return TRUE;
}
$view_modes_info = entity_get_view_modes($this->entityTypeId);
$view_modes_info = $this->entityManager->getViewModes($this->entityTypeId);
return !empty($view_modes_info[$view_mode]['cache']);
}
......
......@@ -8,6 +8,8 @@
namespace Drupal\custom_block\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Session\AccountInterface;
......@@ -33,6 +35,13 @@ class CustomBlockBlock extends BlockBase implements ContainerFactoryPluginInterf
*/
protected $blockManager;
/**
* The entity manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* The Module Handler.
*
......@@ -58,15 +67,18 @@ class CustomBlockBlock extends BlockBase implements ContainerFactoryPluginInterf
* The plugin implementation definition.
* @param \Drupal\block\Plugin\Type\BlockManager
* The Plugin Block Manager.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The Module Handler.
* @param \Drupal\Core\Session\AccountInterface $account
* The account for which view access should be checked.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, BlockManager $block_manager, ModuleHandlerInterface $module_handler, AccountInterface $account) {
public function __construct(array $configuration, $plugin_id, array $plugin_definition, BlockManager $block_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $account) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->blockManager = $block_manager;
$this->entityManager = $entity_manager;
$this->moduleHandler = $module_handler;
$this->account = $account;
}
......@@ -80,6 +92,7 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_id,
$plugin_definition,
$container->get('plugin.manager.block'),
$container->get('entity.manager'),
$container->get('module_handler'),
$container->get('current_user')
);
......@@ -108,14 +121,9 @@ public function defaultConfiguration() {
* Adds body and description fields to the block configuration form.
*/
public function blockForm($form, &$form_state) {
$options = array('default' => t('Default'));
$view_modes = entity_get_view_modes('custom_block');
foreach ($view_modes as $view_mode => $detail) {
$options[$view_mode] = $detail['label'];
}
$form['custom_block']['view_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#options' => $this->entityManager->getViewModeOptions('custom_block'),
'#title' => t('View mode'),
'#description' => t('Output the block in this view mode.'),
'#default_value' => $this->configuration['view_mode']
......
......@@ -80,7 +80,6 @@ public function testCustomBlockCreation() {
// Test the available view mode options.
$this->assertOption('edit-settings-custom-block-view-mode', 'default', 'The default view mode is available.');
$this->assertOption('edit-settings-custom-block-view-mode', 'full', 'The full view mode is available.');
// Check that the block exists in the database.
$blocks = entity_load_multiple_by_properties('custom_block', array('info' => $edit['info']));
......
......@@ -74,7 +74,7 @@ public function preRender($result) {
* in views_plugin_row_comment|node_rss.inc
*/
function options_form_summary_options() {
$view_modes = entity_get_view_modes('node');
$view_modes = \Drupal::entityManager()->getViewModes('node');
$options = array();
foreach ($view_modes as $mode => $settings) {
$options[$mode] = $settings['label'];
......
......@@ -265,7 +265,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
* @see hook_edit_render_field()
*/
protected function renderField(EntityInterface $entity, $field_name, $langcode, $view_mode_id) {
$entity_view_mode_ids = array_keys(entity_get_view_modes($entity->getEntityTypeId()));
$entity_view_mode_ids = array_keys($this->entityManager()->getViewModes($entity->getEntityTypeId()));
if (in_array($view_mode_id, $entity_view_mode_ids)) {
$entity = \Drupal::entityManager()->getTranslationFromContext($entity, $langcode);
$output = $entity->get($field_name)->view($view_mode_id);
......
......@@ -24,14 +24,14 @@
* display settings, or just replicate the settings of the 'default' form mode,
* thus reducing the amount of form display configurations to keep track of.
*
* @see entity_get_form_modes()
* @see \Drupal\Core\Entity\EntityManagerInterface::getAllFormModes()
* @see \Drupal\Core\Entity\EntityManagerInterface::getFormModes()
* @see hook_entity_form_mode_info_alter()
*
* @ConfigEntityType(
* id = "form_mode",
* label = @Translation("Form mode"),
* controllers = {
* "storage" = "Drupal\entity\EntityDisplayModeStorageController",
* "list_builder" = "Drupal\entity\EntityFormModeListBuilder",
* "form" = {
* "add" = "Drupal\entity\Form\EntityFormModeAddForm",
......
......@@ -25,7 +25,8 @@
* replicate the settings of the 'default' view mode, thus reducing the amount
* of display configurations to keep track of.
*
* @see entity_get_view_modes()
* @see \Drupal\Core\Entity\EntityManagerInterface::getAllViewModes()
* @see \Drupal\Core\Entity\EntityManagerInterface::getViewModes()
* @see hook_entity_view_mode_info_alter()
*
* @ConfigEntityType(
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Entity\EntityStorageControllerInterface;
/**
* Base class for config entity types that hold settings for form and view modes.
......@@ -88,4 +89,20 @@ public function calculateDependencies() {
return $this->dependencies;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageControllerInterface $storage_controller) {
parent::preSave($storage_controller);
\Drupal::entityManager()->clearCachedDefinitions();
}
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageControllerInterface $storage_controller, array $entities) {
parent::preDelete($storage_controller, $entities);
\Drupal::entityManager()->clearCachedDefinitions();
}
}
<?php
/**
* @file
* Contains \Drupal\entity\EntityDisplayModeStorageController.
*/
namespace Drupal\entity;
use Drupal\Core\Config\Entity\ConfigStorageController;
use Drupal\Core\Entity\EntityInterface;
/**
* Defines the storage controller class for entity form and view modes.
*/
class EntityDisplayModeStorageController extends ConfigStorageController {
/**
* {@inheritdoc}
*/
protected function preSave(EntityInterface $view_mode) {
entity_info_cache_clear();
}
/**
* {@inheritdoc}
*/
protected function preDelete($view_modes) {
entity_info_cache_clear();
}
}
......@@ -32,15 +32,9 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
* {@inheritdoc}
*/
public function settingsForm(array $form, array &$form_state) {
$view_modes = entity_get_view_modes($this->getFieldSetting('target_type'));
$options = array('default' => t('Default'));
foreach ($view_modes as $view_mode => $view_mode_settings) {
$options[$view_mode] = $view_mode_settings['label'];
}
$elements['view_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#options' => \Drupal::entityManager()->getViewModeOptions($this->getFieldSetting('target_type')),
'#title' => t('View mode'),
'#default_value' => $this->getSetting('view_mode'),
'#required' => TRUE,
......@@ -61,12 +55,9 @@ public function settingsForm(array $form, array &$form_state) {
public function settingsSummary() {
$summary = array();
$view_modes = entity_get_view_modes($this->getFieldSetting('target_type'));
$view_modes = \Drupal::entityManager()->getViewModeOptions($this->getFieldSetting('target_type'));
$view_mode = $this->getSetting('view_mode');
if ($view_mode == 'default') {
$view_mode = t('Default');
}
$summary[] = t('Rendered as @mode', array('@mode' => isset($view_modes[$view_mode]['label']) ? $view_modes[$view_mode]['label'] : $view_mode));
$summary[] = t('Rendered as @mode', array('@mode' => isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : $view_mode));
$summary[] = $this->getSetting('links') ? t('Display links') : t('Do not display links');
return $summary;
......
......@@ -438,11 +438,11 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
$displays_to_update = array();
foreach ($instances as $instance) {
if (!$instance->deleted) {
$view_modes = array('default' => array()) + entity_get_view_modes($instance->entity_type);
$view_modes = \Drupal::entityManager()->getViewModeOptions($instance->entity_type, TRUE);
foreach (array_keys($view_modes) as $mode) {
$displays_to_update['entity_view_display'][$instance->entity_type . '.' . $instance->bundle . '.' . $mode][] = $instance->field->name;
}
$form_modes = array('default' => array()) + entity_get_form_modes($instance->entity_type);
$form_modes = \Drupal::entityManager()->getFormModeOptions($instance->entity_type, TRUE);
foreach (array_keys($form_modes) as $mode) {
$displays_to_update['entity_form_display'][$instance->entity_type . '.' . $instance->bundle . '.' . $mode][] = $instance->field->name;
}
......
......@@ -176,7 +176,7 @@ protected function getDefaultPlugin($field_type) {
* {@inheritdoc}
*/
protected function getDisplayModes() {
return entity_get_view_modes($this->entity_type);
return $this->entityManager->getViewModes($this->entity_type);
}
/**
......
......@@ -143,7 +143,7 @@ protected function getDefaultPlugin($field_type) {
* {@inheritdoc}
*/
protected function getDisplayModes() {
return entity_get_form_modes($this->entity_type);
return $this->entityManager->getFormModes($this->entity_type);
}
/**
......
......@@ -134,7 +134,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
// One local task for each form mode.
$weight = 0;
foreach (entity_get_form_modes($entity_type_id) as $form_mode => $form_mode_info) {
foreach ($this->entityManager->getFormModes($entity_type_id) as $form_mode => $form_mode_info) {
$this->derivatives['field_form_display_' . $form_mode . '_' . $entity_type_id] = array(
'title' => $form_mode_info['label'],
'route_name' => "field_ui.form_display_overview_form_mode_$entity_type_id",
......@@ -148,7 +148,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
// One local task for each view mode.
$weight = 0;
foreach (entity_get_view_modes($entity_type_id) as $view_mode => $form_mode_info) {
foreach ($this->entityManager->getViewModes($entity_type_id) as $view_mode => $form_mode_info) {
$this->derivatives['field_display_' . $view_mode . '_' . $entity_type_id] = array(
'title' => $form_mode_info['label'],
'route_name' => "field_ui.display_overview_view_mode_$entity_type_id",
......@@ -185,11 +185,11 @@ public function alterLocalTasks(&$local_tasks) {
$local_tasks["field_ui.fields:field_form_display_default_$entity_type"]['base_route'] = $admin_form;
$local_tasks["field_ui.fields:field_display_default_$entity_type"]['base_route'] = $admin_form;
foreach (entity_get_form_modes($entity_type) as $form_mode => $form_mode_info) {
foreach ($this->entityManager->getFormModes($entity_type) as $form_mode => $form_mode_info) {
$local_tasks['field_ui.fields:field_form_display_' . $form_mode . '_' . $entity_type]['base_route'] = $admin_form;
}
foreach (entity_get_view_modes($entity_type) as $view_mode => $form_mode_info) {
foreach ($this->entityManager->getViewModes($entity_type) as $view_mode => $form_mode_info) {
$local_tasks['field_ui.fields:field_display_' . $view_mode . '_' . $entity_type]['base_route'] = $admin_form;
}
}
......
......@@ -62,7 +62,7 @@ public function buildOptionsForm(&$form, &$form_state) {
* Return the main options, which are shown in the summary title.
*/
public function buildOptionsForm_summary_options() {
$view_modes = entity_get_view_modes('node');
$view_modes = \Drupal::entityManager()->getViewModes('node');
$options = array();
foreach ($view_modes as $mode => $settings) {
$options[$mode] = $settings['label'];
......
......@@ -429,7 +429,7 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') {
// The teaser view mode is created by the Standard profile and therefore
// might not exist.
$view_modes = entity_get_view_modes('node');
$view_modes = \Drupal::entityManager()->getViewModes('node');
if (isset($view_modes['teaser'])) {
entity_get_display('node', $type->type, 'teaser')
->setComponent('body', array(
......
......@@ -144,7 +144,8 @@ function hook_entity_type_alter(array &$entity_types) {
* @param array $view_modes
* An array of view modes, keyed first by entity type, then by view mode name.
*
* @see entity_get_view_modes()
* @see \Drupal\Core\Entity\EntityManagerInterface::getAllViewModes()
* @see \Drupal\Core\Entity\EntityManagerInterface::getViewModes()
* @see hook_entity_view_mode_info()
*/
function hook_entity_view_mode_info_alter(&$view_modes) {
......
......@@ -57,10 +57,9 @@ protected function defineOptions() {
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$options = $this->buildViewModeOptions();
$form['view_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#options' => \Drupal::entityManager()->getViewModeOptions($this->entityType),
'#title' => t('View mode'),
'#default_value' => $this->options['view_mode'],
);
......@@ -79,22 +78,6 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
/**
* Return the main options, which are shown in the summary title.
*
* @return array
* All view modes of the entity type.
*/
protected function buildViewModeOptions() {
$options = array('default' => t('Default'));
$view_modes = entity_get_view_modes($this->entityType);
foreach ($view_modes as $mode => $settings) {
$options[$mode] = $settings['label'];
}
return $options;
}
/**
* {@inheritdoc}
*/
......
......@@ -128,10 +128,9 @@ protected function defineOptions() {
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$options = $this->buildViewModeOptions();
$form['view_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#options' => \Drupal::entityManager()->getViewModeOptions($this->entityTypeId),
'#title' => t('View mode'),
'#default_value' => $this->options['view_mode'],
);
......@@ -146,19 +145,6 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
/**