You are here

function _ief_table_view_mode_create_ief_table_view_mode in Inline Entity Form Table View Mode 8.2

Check and create the view mode ief_table for the target entity type.

Parameters

\Drupal\field\FieldConfigInterface $fieldConfig: The field configuration.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to _ief_table_view_mode_create_ief_table_view_mode()
ief_table_view_mode_entity_update in ./ief_table_view_mode.module
Implements hook_entity_update().

File

./ief_table_view_mode.module, line 154
Defines a view mode to set up the columns of the table for the IEF widget.

Code

function _ief_table_view_mode_create_ief_table_view_mode(FieldConfigInterface $fieldConfig) {
  $target_entity_type = $fieldConfig
    ->getSetting('target_type');
  $ief_view_mode = $target_entity_type . '.' . EntityInlineTableViewModeForm::IEF_TABLE_VIEW_MODE_NAME;

  // Create the view mode ief_table if not exists.
  if (!EntityViewMode::load($ief_view_mode)) {
    $view_mode = EntityViewMode::create([
      'id' => $ief_view_mode,
      'label' => 'Inline Entity Form Table',
      'targetEntityType' => $target_entity_type,
    ]);
    $view_mode
      ->save();
  }
}