You are here

public function UpdateManager::executeAllInConsole in Lightning Core 8.3

Same name and namespace in other branches
  1. 8.5 src/UpdateManager.php \Drupal\lightning_core\UpdateManager::executeAllInConsole()
  2. 8 src/UpdateManager.php \Drupal\lightning_core\UpdateManager::executeAllInConsole()
  3. 8.2 src/UpdateManager.php \Drupal\lightning_core\UpdateManager::executeAllInConsole()
  4. 8.4 src/UpdateManager.php \Drupal\lightning_core\UpdateManager::executeAllInConsole()

Executes all available updates in a console context.

Parameters

\Symfony\Component\Console\Style\StyleInterface $style: The I/O style.

File

src/UpdateManager.php, line 207

Class

UpdateManager

Namespace

Drupal\lightning_core

Code

public function executeAllInConsole(StyleInterface $style) {
  $updates = $this
    ->getAvailable();
  if (sizeof($updates) === 0) {
    return $style
      ->text('There are no updates available.');
  }
  $style
    ->text("Executing all available updates...");
  $provider = NULL;
  $versions = $this->configFactory
    ->getEditable(static::CONFIG_NAME);
  foreach ($updates as $update) {
    if ($update['provider'] != $provider) {
      $provider = $update['provider'];
      $style
        ->text($provider . ' ' . $update['id']);
    }
    $handler = $this->classResolver
      ->getInstanceFromDefinition($update['class']);

    /** @var \Drupal\lightning_core\UpdateTask $task */
    foreach ($this
      ->getTasks($handler) as $task) {
      $task
        ->execute($style);
    }
    $versions
      ->set($provider, $update['id'])
      ->save();
  }
}