You are here

public function Field::evaluate in Security Review 8

Returns the evaluation page of a result.

Usually this is a list of the findings and an explanation.

Parameters

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

Return value

array The render array of the evaluation page.

Overrides Check::evaluate

File

src/Checks/Field.php, line 126

Class

Field
Checks for Javascript and PHP in submitted content.

Namespace

Drupal\security_review\Checks

Code

public function evaluate(CheckResult $result) {
  $findings = $result
    ->findings();
  if (empty($findings)) {
    return [];
  }
  $paragraphs = [];
  $paragraphs[] = $this
    ->t('The following items potentially have dangerous tags.');
  $items = [];
  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) {
        $items[] = $this
          ->t('@vulnerabilities found in <em>@field</em> field of <a href=":url">@label</a>', [
          '@vulnerabilities' => implode(' and ', $finding),
          '@field' => $field,
          '@label' => $entity
            ->label(),
          ':url' => $this
            ->getEntityLink($entity),
        ]);
      }
    }
  }
  return [
    '#theme' => 'check_evaluation',
    '#paragraphs' => $paragraphs,
    '#items' => $items,
  ];
}