You are here

public function Updater::begin in Automatic Updates 8.2

Begins the update.

Parameters

string[] $project_versions: The versions of the packages to update to, keyed by package name.

Return value

string A key for this stage update process.

Throws

\InvalidArgumentException Thrown if no project version for Drupal core is provided.

File

src/Updater.php, line 140

Class

Updater
Defines a service to perform updates.

Namespace

Drupal\automatic_updates

Code

public function begin(array $project_versions) : string {
  if (count($project_versions) !== 1 || !array_key_exists('drupal', $project_versions)) {
    throw new \InvalidArgumentException("Currently only updates to Drupal core are supported.");
  }
  $composer = ComposerUtility::createForDirectory($this->pathLocator
    ->getActiveDirectory());
  $packages = [];
  foreach ($composer
    ->getCorePackageNames() as $package) {
    $packages[$package] = $project_versions['drupal'];
  }
  $stage_key = $this
    ->createActiveStage($packages);

  /** @var \Drupal\automatic_updates\Event\PreStartEvent $event */
  $event = $this
    ->dispatchUpdateEvent(new PreStartEvent($composer, $packages), AutomaticUpdatesEvents::PRE_START);
  $this->beginner
    ->begin($this->pathLocator
    ->getActiveDirectory(), $this->pathLocator
    ->getStageDirectory(), $this
    ->getExclusions($event));
  return $stage_key;
}