function FieldHooks::fieldConfigInsert

Implements hook_ENTITY_TYPE_insert() for 'field_config'.

File

core/modules/field/src/Hook/FieldHooks.php, line 294

Class

FieldHooks
Hook implementations for field.

Namespace

Drupal\field\Hook

Code

public function fieldConfigInsert(FieldConfigInterface $field) {
    if ($field->isSyncing()) {
        // Don't change anything during a configuration sync.
        return;
    }
    // Allow other view modes to update their configuration for the new field.
    // Otherwise, configuration for view modes won't get updated until the mode
    // is used for the first time, creating noise in config diffs.
    \Drupal::classResolver(EntityDisplayRebuilder::class)->rebuildEntityTypeDisplays($field->getTargetEntityTypeId(), $field->getTargetBundle());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.