protected function FieldStorageConfig::preSaveUpdated in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 363 
- Contains \Drupal\field\Entity\FieldStorageConfig.
Class
- FieldStorageConfig
- Defines the Field storage configuration entity.
Namespace
Drupal\field\EntityCode
protected function preSaveUpdated(EntityStorageInterface $storage) {
  $module_handler = \Drupal::moduleHandler();
  $entity_manager = \Drupal::entityManager();
  // Some updates are always disallowed.
  if ($this
    ->getType() != $this->original
    ->getType()) {
    throw new FieldException("Cannot change the field type for an existing field storage.");
  }
  if ($this
    ->getTargetEntityTypeId() != $this->original
    ->getTargetEntityTypeId()) {
    throw new FieldException("Cannot change the entity type for an existing field storage.");
  }
  // 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', array(
    $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.
  $entity_manager
    ->onFieldStorageDefinitionUpdate($this, $this->original);
}