You are here

public static function Updater::factory in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Updater/Updater.php \Drupal\Core\Updater\Updater::factory()

Returns an Updater of the appropriate type depending on the source.

If a directory is provided which contains a module, will return a ModuleUpdater.

Parameters

string $source: Directory of a Drupal project.

string $root: The root directory under which the project will be copied to if it's a new project. Usually this is the app root (the directory in which the Drupal site is installed).

Return value

\Drupal\Core\Updater\Updater A new Drupal\Core\Updater\Updater object.

Throws

\Drupal\Core\Updater\UpdaterException

2 calls to Updater::factory()
UpdateManagerInstall::submitForm in core/modules/update/src/Form/UpdateManagerInstall.php
Form submission handler.
UpdateReady::submitForm in core/modules/update/src/Form/UpdateReady.php
Form submission handler.

File

core/lib/Drupal/Core/Updater/Updater.php, line 62

Class

Updater
Defines the base class for Updaters used in Drupal.

Namespace

Drupal\Core\Updater

Code

public static function factory($source, $root) {
  if (is_dir($source)) {
    $updater = self::getUpdaterFromDirectory($source);
  }
  else {
    throw new UpdaterException('Unable to determine the type of the source directory.');
  }
  return new $updater($source, $root);
}