function Updater::getUpdaterFromDirectory

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

Determines 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.

Throws

\Drupal\Core\Updater\UpdaterException

2 calls to Updater::getUpdaterFromDirectory()
Updater::factory in core/lib/Drupal/Core/Updater/Updater.php
Returns an Updater of the appropriate type depending on the source.
UpdateUploadTest::testUpdateDirectory in core/modules/update/tests/src/Functional/UpdateUploadTest.php
Tests only an *.info.yml file are detected without supporting files.

File

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

Class

Updater
Defines the base class for Updaters used in Drupal.

Namespace

Drupal\Core\Updater

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([
            $class,
            'canUpdateDirectory',
        ], $directory)) {
            return $class;
        }
    }
    throw new UpdaterException('Cannot determine the type of project.');
}

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