You are here

function message_ui_entity_insert in Message UI 8

Implements hook_entity_insert().

File

./message_ui.module, line 29
Contains Drupal\message_ui\message_ui.module.

Code

function message_ui_entity_insert(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() != 'field_config') {
    return;
  }
  if ($entity
    ->get('entity_type') != 'message') {
    return;
  }

  // Prevent interruption of config sync.
  if (\Drupal::isConfigSyncing()) {
    return;
  }

  // A new field was attached to the message template. We will make sure it will
  // appear in message form.
  \Drupal::service('message_ui.field_display_manager')
    ->SetFieldsDisplay($entity
    ->get('bundle'));
}