You are here

class SecurityReview in DRD Agent 8.3

Same name and namespace in other branches
  1. 4.0.x src/Agent/Remote/SecurityReview.php \Drupal\drd_agent\Agent\Remote\SecurityReview

Implements the SecurityReview class.

Hierarchy

Expanded class hierarchy of SecurityReview

1 file declares its use of SecurityReview
Info.php in src/Agent/Action/Info.php

File

src/Agent/Remote/SecurityReview.php, line 12

Namespace

Drupal\drd_agent\Agent\Remote
View source
class SecurityReview extends Base {

  /**
   * {@inheritdoc}
   */
  public function collect() : array {
    $review = [];
    if ($this->moduleHandler
      ->moduleExists('security_review')) {

      /** @var \Drupal\security_review\SecurityReview $security_review */
      $security_review = $this->container
        ->get('security_review');

      // Only check once per day.
      if ($this->time
        ->getRequestTime() - $security_review
        ->getLastRun() > 86400) {

        /** @var \Drupal\Core\Session\AccountSwitcherInterface $switcher */
        $switcher = $this->container
          ->get('account_switcher');
        $switcher
          ->switchTo(new UserSession([
          'uid' => 1,
        ]));

        /** @var \Drupal\security_review\Checklist $checklist */
        $checklist = $this->container
          ->get('security_review.checklist');
        $checklist
          ->runChecklist();
        $switcher
          ->switchBack();
      }
      $clc = ChecklistController::create($this->container);
      $review['security_review'] = [
        'title' => t('Security Review'),
        'result' => $clc
          ->results(),
      ];
    }
    return $review;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Base::$accountSwitcher protected property
Base::$configFactory protected property
Base::$container protected property
Base::$database protected property
Base::$entityTypeManager protected property
Base::$moduleHandler protected property
Base::$time protected property
Base::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
Base::__construct public function Base constructor.
SecurityReview::collect public function Collect the security review results. Overrides BaseInterface::collect