Saves an updated field instance definition.
SAVED_UPDATED if the definition was saved.
\Drupal\field\FieldException If the field instance definition is invalid.
\Drupal\Core\Entity\EntityStorageException In case of failures at the configuration storage level.
protected function saveUpdated() {
$module_handler = \Drupal::moduleHandler();
$instance_controller = \Drupal::entityManager()
->getStorageController($this->entityType);
$original = $instance_controller
->loadUnchanged($this
->getOriginalID());
// Some updates are always disallowed.
if ($this->entity_type != $original->entity_type) {
throw new FieldException("Cannot change an existing instance's entity_type.");
}
if ($this->bundle != $original->bundle && empty($this->bundle_rename_allowed)) {
throw new FieldException("Cannot change an existing instance's bundle.");
}
if ($this->field_uuid != $original->field_uuid) {
throw new FieldException("Cannot change an existing instance's field.");
}
// Ensure default values are present.
$this
->prepareSave();
// Save the configuration.
$result = parent::save();
field_cache_clear();
// Invoke hook_field_update_instance() after the cache is cleared for API
// consistency.
$module_handler
->invokeAll('field_update_instance', array(
$this,
$original,
));
return $result;
}