You are here

private function SecurityReviewController::getSecurityReviewRunCheck in Acquia Connector 8.2

Same name and namespace in other branches
  1. 8 src/Controller/SecurityReviewController.php \Drupal\acquia_connector\Controller\SecurityReviewController::getSecurityReviewRunCheck()
  2. 3.x src/Controller/SecurityReviewController.php \Drupal\acquia_connector\Controller\SecurityReviewController::getSecurityReviewRunCheck()

Run a single Security Review check.

1 call to SecurityReviewController::getSecurityReviewRunCheck()
SecurityReviewController::getSecurityReviewResults in src/Controller/SecurityReviewController.php
Private function the review and returns the full results.

File

src/Controller/SecurityReviewController.php, line 111

Class

SecurityReviewController
Acquia Security Review page.

Namespace

Drupal\acquia_connector\Controller

Code

private function getSecurityReviewRunCheck($module, $check_name, $check, $log, $store = FALSE) {
  $return = [
    'result' => NULL,
  ];
  if (isset($check['file'])) {

    // Handle Security Review defining checks for other modules.
    if (isset($check['module'])) {
      $module = $check['module'];
    }
    module_load_include('inc', $module, $check['file']);
  }
  $function = $check['callback'];
  if (method_exists($this, $function)) {
    $return = call_user_func([
      __NAMESPACE__ . '\\SecurityReviewController',
      $function,
    ]);
  }
  $check_result = array_merge($check, $return);
  $check_result['lastrun'] = \Drupal::time()
    ->getRequestTime();

  // Do not log if result is NULL.
  if ($log && !is_null($return['result'])) {
    $variables = [
      '@name' => $check_result['title'],
    ];
    if ($check_result['result']) {
      $this
        ->getSecurityReviewLog($module, $check_name, '@name check passed', $variables, WATCHDOG_INFO);
    }
    else {
      $this
        ->getSecurityReviewLog($module, $check_name, '@name check failed', $variables, WATCHDOG_ERROR);
    }
  }
  return $check_result;
}