You are here

function ief_table_view_mode_entity_update in Inline Entity Form Table View Mode 8.2

Implements hook_entity_update().

File

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

Code

function ief_table_view_mode_entity_update(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() == 'entity_form_display') {
    foreach ($entity
      ->getComponents() as $component_name => $component) {
      if (isset($component['type']) && $component['type'] == 'inline_entity_form_complex_table_view_mode') {

        /** @var \Drupal\field\Entity\FieldConfigInterface $field_config */
        $field_config = FieldConfig::load($entity
          ->getTargetEntityTypeId() . '.' . $entity
          ->getTargetBundle() . '.' . $component_name);
        if ($field_config) {
          try {
            _ief_table_view_mode_create_ief_table_view_mode($field_config);
          } catch (EntityStorageException $e) {
          }
        }
      }
    }
  }
}