You are here

public function ReadinessCheckerManager::run in Automatic Updates 8

Run checks.

Parameters

string $category: The category of check.

Return value

array An array of translatable strings.

Overrides ReadinessCheckerManagerInterface::run

File

src/ReadinessChecker/ReadinessCheckerManager.php, line 64

Class

ReadinessCheckerManager
Defines a chained readiness checker implementation combining multiple checks.

Namespace

Drupal\automatic_updates\ReadinessChecker

Code

public function run($category) {
  $messages = [];
  if (!$this
    ->isEnabled()) {
    return $messages;
  }
  if (!isset($this
    ->getSortedCheckers()[$category])) {
    throw new \InvalidArgumentException(sprintf('No readiness checkers exist of category "%s"', $category));
  }
  foreach ($this
    ->getSortedCheckers()[$category] as $checker) {
    $messages[] = $checker
      ->run();
  }
  $messages = array_merge(...$messages);
  $this->keyValue
    ->set("readiness_check_results.{$category}", $messages);
  $this->keyValue
    ->set('readiness_check_timestamp', \Drupal::time()
    ->getRequestTime());
  return $messages;
}