You are here

protected function DevelEntityUpdatesCommands::doEntityUpdates in Devel Entity Updates 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Commands/DevelEntityUpdatesCommands.php \Drupal\devel_entity_updates\Commands\DevelEntityUpdatesCommands::doEntityUpdates()
  2. 8 src/Commands/DevelEntityUpdatesCommands.php \Drupal\devel_entity_updates\Commands\DevelEntityUpdatesCommands::doEntityUpdates()
  3. 3.x src/Commands/DevelEntityUpdatesCommands.php \Drupal\devel_entity_updates\Commands\DevelEntityUpdatesCommands::doEntityUpdates()

Actually performs entity schema updates.

Return value

bool TRUE if updates were applied, FALSE otherwise.

1 call to DevelEntityUpdatesCommands::doEntityUpdates()
DevelEntityUpdatesCommands::entityUpdates in src/Commands/DevelEntityUpdatesCommands.php
Apply pending entity schema updates.

File

src/Commands/DevelEntityUpdatesCommands.php, line 83

Class

DevelEntityUpdatesCommands
Drush9 commands definitions.

Namespace

Drupal\devel_entity_updates\Commands

Code

protected function doEntityUpdates() {
  $result = TRUE;
  $change_summary = $this->entityDefinitionUpdateManager
    ->getChangeSummary();
  if (!empty($change_summary)) {
    $this
      ->output()
      ->writeln(dt('The following updates are pending:'));
    $this
      ->io()
      ->newLine();
    foreach ($change_summary as $entity_type_id => $changes) {
      $this
        ->output()
        ->writeln($entity_type_id . ' entity type : ');
      foreach ($changes as $change) {
        $this
          ->output()
          ->writeln(strip_tags($change), 2);
      }
    }
    if (!$this
      ->io()
      ->confirm(dt('Do you wish to run all pending updates?'))) {
      throw new UserAbortException();
    }
    $this->classResolver
      ->getInstanceFromDefinition(DevelEntityDefinitionUpdateManager::class)
      ->applyUpdates();
  }
  else {
    $this
      ->logger()
      ->success(dt("No entity schema updates required"));
    $result = FALSE;
  }
  return $result;
}