function entity_update_tests_update_8002 in Entity Update 8
Same name and namespace in other branches
- 2.0.x tests/modules/entity_update_tests/entity_update_tests.install \entity_update_tests_update_8002()
Update 02 - Example for Add fields (Not recomended, do one by one).
File
- modules/
entity_update_tests/ entity_update_tests.install, line 45 - Entity update test module (entity_update_tests).
Code
function entity_update_tests_update_8002() {
// Entity checking process : Get current entities list.
$ids_old = \Drupal::entityQuery('entity_update_tests_cnt')
->execute();
// Make Update Using full methode.
if (!EntityUpdate::safeUpdateMain()) {
// Your codes if update failed.
throw new UpdateException('Entity update failed.');
}
// Entity checking process : Compare with new list entities list.
$ids_new = \Drupal::entityQuery('entity_update_tests_cnt')
->execute();
// Compare two lists.
$result = array_diff($ids_old, $ids_new);
if (!empty($result)) {
// Your codes if update checking failed.
throw new UpdateException('Entity update checking failed.');
}
return "Entity update success";
}