function Updater::factory

Same name in other branches
  1. 7.x includes/updater.inc \Updater::factory()
  2. 9 core/lib/Drupal/Core/Updater/Updater.php \Drupal\Core\Updater\Updater::factory()
  3. 8.9.x core/lib/Drupal/Core/Updater/Updater.php \Drupal\Core\Updater\Updater::factory()
  4. 11.x 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 72

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.