You are here

class RunUpdatesCommand in Scheduled Updates 8

Same name in this branch
  1. 8 src/Command/RunUpdatesCommand.php \Drupal\scheduled_updates\Command\RunUpdatesCommand
  2. 8 src/Commands/RunUpdatesCommand.php \Drupal\scheduled_updates\Commands\RunUpdatesCommand

Class RunUpdatesCommand.

@package Drupal\scheduled_updates

Hierarchy

  • class \Drupal\scheduled_updates\Command\RunUpdatesCommand extends \Drupal\Console\Command\ContainerAwareCommand

Expanded class hierarchy of RunUpdatesCommand

File

src/Command/RunUpdatesCommand.php, line 22
Contains \Drupal\scheduled_updates\Command\RunUpdatesCommand.

Namespace

Drupal\scheduled_updates\Command
View source
class RunUpdatesCommand extends ContainerAwareCommand {

  /**
   * {@inheritdoc}
   */
  protected function configure() {
    $this
      ->setName('scheduled_updates:run_updates')
      ->setDescription($this
      ->trans('command.scheduled_updates.run_updates.description'))
      ->addArgument('update_types', InputArgument::OPTIONAL, $this
      ->trans('command.scheduled_updates.run_updates.arguments.update_types'));
  }

  /**
   * {@inheritdoc}
   */
  protected function execute(InputInterface $input, OutputInterface $output) {
    $io = new DrupalStyle($input, $output);

    /** @var UpdateRunnerUtils $runnerUtils */
    if ($runnerUtils = $this
      ->hasGetService('scheduled_updates.update_runner')) {
      $update_types = $input
        ->getArgument('update_types');
      if ($update_types) {
        $update_types = explode(',', $update_types);
      }
      else {
        $update_types = [];
      }
      $this->runnerUtils
        ->runAllUpdates($update_types, true);
      $io
        ->info('Updates run!');
    }
    else {
      $io
        ->error('Could not get Global Runner service. No updates run.');
    }
  }

}

Members