You are here

public function DrushCommands::mediaEntityCheckUpgrade in Media entity 8.2

Check upgrade requirements for Media Entity into Media in core.

@command media_entity:check-upgrade @usage drush mecu Checks upgrade requirements for Media Entity while upgrading to Media in core. @aliases mecu,media-entity-check-upgrade

File

src/Commands/DrushCommands.php, line 39

Class

DrushCommands
Add commands for Drush 9.

Namespace

Drupal\media_entity\Commands

Code

public function mediaEntityCheckUpgrade() {
  $logger = $this
    ->logger();

  // This command is useless if the DB updates have already been run.
  if (drupal_get_installed_schema_version('media_entity') >= 8201) {
    $logger
      ->success(dt('Your site has already run the media_entity DB updates. If you believe this is not correct, you should consider rolling back your database to a previous backup and try again.'));
    return;
  }
  $checks = $this->cliService
    ->validateDbUpdateRequirements();
  if (empty($checks['errors'])) {
    $logger
      ->success(sprintf("\33[1;32;40m\33[1m%s\33[0m", '✓') . ' ' . dt('All upgrade requirements are met and you can proceed with the DB updates.'));
  }
  else {
    $logger
      ->error(sprintf("\33[31;40m\33[1m%s\33[0m", '✗') . ' ' . dt('Your site did not pass all upgrade checks. You can find more information in the error messages below.'));
  }
  foreach ($checks['passes'] as $pass_msg) {
    $logger
      ->success($pass_msg);
  }
  foreach ($checks['errors'] as $error_msg) {
    $logger
      ->error($error_msg);
  }
}