function devel_entity_updates_main in Devel Entity Updates 3.x
Same name and namespace in other branches
- 8.2 drush/devel_entity_updates.drush8.inc \devel_entity_updates_main()
- 8 drush/devel_entity_updates.drush8.inc \devel_entity_updates_main()
- 3.0.x drush/devel_entity_updates.drush8.inc \devel_entity_updates_main()
Apply pending entity schema updates.
1 call to devel_entity_updates_main()
- drush_devel_entity_updates in drush/
devel_entity_updates.drush8.inc - Command handler. Apply pending entity schema updates.
File
- drush/
devel_entity_updates.drush8.inc, line 60 - Drush8 commands definitions.
Code
function devel_entity_updates_main() {
$result = TRUE;
$change_summary = \Drupal::entityDefinitionUpdateManager()
->getChangeSummary();
if (!empty($change_summary)) {
drush_print(dt('The following updates are pending:'));
drush_print();
foreach ($change_summary as $entity_type_id => $changes) {
drush_print($entity_type_id . ' entity type : ');
foreach ($changes as $change) {
drush_print(strip_tags($change), 2);
}
}
if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
return drush_user_abort();
}
try {
\Drupal::classResolver()
->getInstanceFromDefinition(DevelEntityDefinitionUpdateManager::class)
->applyUpdates();
} catch (EntityStorageException $e) {
watchdog_exception('update', $e);
}
}
else {
drush_log(dt("No entity schema updates required"), LogLevel::SUCCESS);
$result = FALSE;
}
return $result;
}