public function FieldStorageConfig::preSave in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field/src/Entity/FieldStorageConfig.php \Drupal\field\Entity\FieldStorageConfig::preSave()
Overrides \Drupal\Core\Entity\Entity::preSave().
Throws
\Drupal\Core\Field\FieldException If the field definition is invalid.
\Drupal\Core\Entity\EntityStorageException In case of failures at the configuration storage level.
Overrides ConfigEntityBase::preSave
File
- core/
modules/ field/ src/ Entity/ FieldStorageConfig.php, line 285
Class
- FieldStorageConfig
- Defines the Field storage configuration entity.
Namespace
Drupal\field\EntityCode
public function preSave(EntityStorageInterface $storage) {
// Clear the derived data about the field.
unset($this->schema);
// 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.
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$default_settings = $field_type_manager
->getDefaultStorageSettings($this->type);
$this->settings = array_intersect_key($this->settings, $default_settings) + $default_settings;
if ($this
->isNew()) {
$this
->preSaveNew($storage);
}
else {
$this
->preSaveUpdated($storage);
}
parent::preSave($storage);
}