public function EntityDefinitionUpdateManager::applyUpdates in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php \Drupal\Core\Entity\EntityDefinitionUpdateManager::applyUpdates()
Applies all the detected valid changes.
Use this with care, as it will apply updates for any module, which will lead to unpredictable results.
Throws
\Drupal\Core\Entity\EntityStorageException This exception is thrown if a change cannot be applied without unacceptable data loss. In such a case, the site administrator needs to apply some other process, such as a custom update function or a migration via the Migrate module.
Overrides EntityDefinitionUpdateManagerInterface::applyUpdates
File
- core/
lib/ Drupal/ Core/ Entity/ EntityDefinitionUpdateManager.php, line 98 - Contains \Drupal\Core\Entity\EntityDefinitionUpdateManager.
Class
- EntityDefinitionUpdateManager
- Manages entity definition updates.
Namespace
Drupal\Core\EntityCode
public function applyUpdates() {
$complete_change_list = $this
->getChangeList();
if ($complete_change_list) {
// self::getChangeList() only disables the cache and does not invalidate.
// In case there are changes, explicitly invalidate caches.
$this->entityManager
->clearCachedDefinitions();
}
foreach ($complete_change_list as $entity_type_id => $change_list) {
// Process entity type definition changes before storage definitions ones
// this is necessary when you change an entity type from non-revisionable
// to revisionable and at the same time add revisionable fields to the
// entity type.
if (!empty($change_list['entity_type'])) {
$this
->doEntityUpdate($change_list['entity_type'], $entity_type_id);
}
// Process field storage definition changes.
if (!empty($change_list['field_storage_definitions'])) {
$storage_definitions = $this->entityManager
->getFieldStorageDefinitions($entity_type_id);
$original_storage_definitions = $this->entityManager
->getLastInstalledFieldStorageDefinitions($entity_type_id);
foreach ($change_list['field_storage_definitions'] as $field_name => $change) {
$storage_definition = isset($storage_definitions[$field_name]) ? $storage_definitions[$field_name] : NULL;
$original_storage_definition = isset($original_storage_definitions[$field_name]) ? $original_storage_definitions[$field_name] : NULL;
$this
->doFieldUpdate($change, $storage_definition, $original_storage_definition);
}
}
}
}