class TestSandboxDatabaseUpdatesValidator
Allows tests to dictate which extensions have staged database updates.
Hierarchy
- class \Drupal\package_manager_test_validation\TestSandboxDatabaseUpdatesValidator extends \Drupal\package_manager\Validator\SandboxDatabaseUpdatesValidator
Expanded class hierarchy of TestSandboxDatabaseUpdatesValidator
File
-
core/
modules/ package_manager/ tests/ modules/ package_manager_test_validation/ src/ TestSandboxDatabaseUpdatesValidator.php, line 14
Namespace
Drupal\package_manager_test_validationView source
class TestSandboxDatabaseUpdatesValidator extends BaseValidator {
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
*/
private $state;
/**
* Sets the state service dependency.
*
* @param \Drupal\Core\State\StateInterface $state
* The state service.
*/
public function setState(StateInterface $state) : void {
$this->state = $state;
}
/**
* Sets the names of the extensions which should have staged database updates.
*
* @param string[]|null $extensions
* The machine names of the extensions which should say they have staged
* database updates, or NULL to defer to the parent class.
*/
public static function setExtensionsWithUpdates(?array $extensions) : void {
\Drupal::state()->set(static::class, $extensions);
}
/**
* {@inheritdoc}
*/
public function hasStagedUpdates(string $stage_dir, Extension $extension) : bool {
$extensions = $this->state
->get(static::class);
if (isset($extensions)) {
return in_array($extension->getName(), $extensions, TRUE);
}
return parent::hasStagedUpdates($stage_dir, $extension);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
TestSandboxDatabaseUpdatesValidator::$state | private | property | The state service. |
TestSandboxDatabaseUpdatesValidator::hasStagedUpdates | public | function | |
TestSandboxDatabaseUpdatesValidator::setExtensionsWithUpdates | public static | function | Sets the names of the extensions which should have staged database updates. |
TestSandboxDatabaseUpdatesValidator::setState | public | function | Sets the state service dependency. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.