$storage_definition =
$this->
getFieldStorageDefinition();
// Filter out unknown settings and make sure all settings are present, so
// that a complete field definition is passed to the various hooks and
// written to config.
$default_settings =
$field_type_manager->
getDefaultFieldSettings($storage_definition->
getType());
$this->settings =
array_intersect_key($this->settings,
$default_settings) +
$default_settings;
if ($this->
isNew()) { // Notify the entity storage.
\Drupal::
service('field_definition.listener'
)->
onFieldDefinitionCreate($this);
} else { // Some updates are always disallowed.
if ($this->entity_type !=
$this->original->entity_type
) { throw new FieldException("Cannot change an existing field's entity_type."
);
} if ($this->bundle !=
$this->original->bundle
) { throw new FieldException("Cannot change an existing field's bundle."
);
} if ($storage_definition->
uuid() !=
$this->original->
getFieldStorageDefinition()->
uuid()) { throw new FieldException("Cannot change an existing field's storage."
);
}