protected function FieldStorageConfig::preSaveUpdated in Drupal 8
Same name and namespace in other branches
- 9 core/modules/field/src/Entity/FieldStorageConfig.php \Drupal\field\Entity\FieldStorageConfig::preSaveUpdated()
Prepares saving an updated field definition.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage.
1 call to FieldStorageConfig::preSaveUpdated()
- FieldStorageConfig::preSave in core/
modules/ field/ src/ Entity/ FieldStorageConfig.php - Overrides \Drupal\Core\Entity\Entity::preSave().
File
- core/
modules/ field/ src/ Entity/ FieldStorageConfig.php, line 367
Class
- FieldStorageConfig
- Defines the Field storage configuration entity.
Namespace
Drupal\field\EntityCode
protected function preSaveUpdated(EntityStorageInterface $storage) {
$module_handler = \Drupal::moduleHandler();
// Some updates are always disallowed.
if ($this
->getType() != $this->original
->getType()) {
throw new FieldException(sprintf('Cannot change the field type for an existing field storage. The field storage %s has the type %s.', $this
->id(), $this->original
->getType()));
}
if ($this
->getTargetEntityTypeId() != $this->original
->getTargetEntityTypeId()) {
throw new FieldException(sprintf('Cannot change the entity type for an existing field storage. The field storage %s has the type %s.', $this
->id(), $this->original
->getTargetEntityTypeId()));
}
// See if any module forbids the update by throwing an exception. This
// invokes hook_field_storage_config_update_forbid().
$module_handler
->invokeAll('field_storage_config_update_forbid', [
$this,
$this->original,
]);
// Notify the entity manager. A listener can reject the definition
// update as invalid by raising an exception, which stops execution before
// the definition is written to config.
\Drupal::service('field_storage_definition.listener')
->onFieldStorageDefinitionUpdate($this, $this->original);
}