You are here

public function Check::storeResult in Security Review 8

Stores a result in the state system.

Parameters

\Drupal\security_review\CheckResult $result: The result to store.

1 call to Check::storeResult()
Check::lastResult in src/Check.php
Returns the last stored result of the check.

File

src/Check.php, line 404

Class

Check
Defines a security check.

Namespace

Drupal\security_review

Code

public function storeResult(CheckResult $result) {
  if ($result == NULL) {
    $context = [
      '@reviewcheck' => $this
        ->getTitle(),
      '@namespace' => $this
        ->getNamespace(),
    ];
    $this
      ->securityReview()
      ->log($this, 'Unable to store check @reviewcheck for @namespace', $context, RfcLogLevel::CRITICAL);
    return;
  }
  $findings = $this
    ->storesFindings() ? $result
    ->findings() : [];
  $this->state
    ->setMultiple([
    $this->statePrefix . 'last_result.result' => $result
      ->result(),
    $this->statePrefix . 'last_result.time' => $result
      ->time(),
    $this->statePrefix . 'last_result.visible' => $result
      ->isVisible(),
    $this->statePrefix . 'last_result.findings' => $findings,
  ]);
}