function Updater::getUpdaterFromDirectory

Same name in other branches
  1. 9 core/lib/Drupal/Core/Updater/Updater.php \Drupal\Core\Updater\Updater::getUpdaterFromDirectory()
  2. 8.9.x core/lib/Drupal/Core/Updater/Updater.php \Drupal\Core\Updater\Updater::getUpdaterFromDirectory()
  3. 10 core/lib/Drupal/Core/Updater/Updater.php \Drupal\Core\Updater\Updater::getUpdaterFromDirectory()
  4. 11.x core/lib/Drupal/Core/Updater/Updater.php \Drupal\Core\Updater\Updater::getUpdaterFromDirectory()

Determine which Updater class can operate on the given directory.

Parameters

string $directory: Extracted Drupal project.

Return value

string The class name which can work with this project type.

1 call to Updater::getUpdaterFromDirectory()
Updater::factory in includes/updater.inc
Return an Updater of the appropriate type depending on the source.

File

includes/updater.inc, line 123

Class

Updater
Base class for Updaters used in Drupal.

Code

public static function getUpdaterFromDirectory($directory) {
    // Gets a list of possible implementing classes.
    $updaters = drupal_get_updaters();
    foreach ($updaters as $updater) {
        $class = $updater['class'];
        if (call_user_func(array(
            $class,
            'canUpdateDirectory',
        ), $directory)) {
            return $class;
        }
    }
    throw new UpdaterException(t('Cannot determine the type of project.'));
}

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