You are here

public function Field::evaluatePlain in Security Review 8

Evaluates a CheckResult and returns a plaintext output.

Parameters

\Drupal\security_review\CheckResult $result: The check result to evaluate.

Return value

string The evaluation string.

Overrides Check::evaluatePlain

File

src/Checks/Field.php, line 196

Class

Field
Checks for Javascript and PHP in submitted content.

Namespace

Drupal\security_review\Checks

Code

public function evaluatePlain(CheckResult $result) {
  $findings = $result
    ->findings();
  if (empty($findings)) {
    return '';
  }
  $output = '';
  foreach ($findings as $entity_type_id => $entities) {
    foreach ($entities as $entity_id => $fields) {
      $entity = $this
        ->entityTypeManager()
        ->getStorage($entity_type_id)
        ->load($entity_id);
      foreach ($fields as $field => $finding) {
        $output .= "\t" . $this
          ->t('@vulnerabilities in @field of :link', [
          '@vulnerabilities' => implode(' and ', $finding),
          '@field' => $field,
          ':link' => $this
            ->getEntityLink($entity),
        ]) . "\n";
      }
    }
  }
  return $output;
}