public static function Updater::factory

public static Updater::factory($source, $root)

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

File

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

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(t('Unable to determine the type of the source directory.'));
  }
  return new $updater($source, $root);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Updater!Updater.php/function/Updater::factory/8.1.x