You are here

private static function EntityUpdate::safeUpdateUninstallFields in Entity Update 8

Update all entities / Uninstall fields.

Return value

bool Update is done or FAIL

1 call to EntityUpdate::safeUpdateUninstallFields()
EntityUpdate::safeUpdateMain in src/EntityUpdate.php
Update all entities.

File

src/EntityUpdate.php, line 134

Class

EntityUpdate
EntityUpdate Main Class.

Namespace

Drupal\entity_update

Code

private static function safeUpdateUninstallFields($entity_change_summerys) {

  // Read and backup data into entity_update entity..
  EntityUpdatePrint::drushPrint("Read and backup data");

  // Backup and delete entities has data, get the data flag.
  $flg_has_data = self::entityUpdateDataBackupDel($entity_change_summerys);

  // Exec Update.
  EntityUpdatePrint::drushPrint("Update entity Schema");
  try {
    \Drupal::entityDefinitionUpdateManager()
      ->applyUpdates();
    EntityUpdatePrint::drushLog('Entities update success', 'ok');
  } catch (Exception $ex) {
    EntityUpdatePrint::drushLog($ex
      ->getMessage(), 'warning');
  }

  // Re create.
  if ($flg_has_data) {
    EntityUpdatePrint::drushPrint("Re creating entities.");

    // Restore entities.
    $result = self::entityUpdateDataRestore();

    // Message to Flush 'entity_update' via drush command.
    EntityUpdatePrint::drushLog("Entiti recreate Success / End", $result ? 'ok' : 'warning');
    EntityUpdatePrint::drushLog("CAUTION : Before next operation, Flush 'Entity Data' using : drush upe --clean", 'warning');
  }

  // No need to update = OK.
  return !\Drupal::entityDefinitionUpdateManager()
    ->needsUpdates();
}