You are here

public function ModuleList::init in Production check & Production monitor 8

Initializes the check plugin.

Overrides ProdCheckBase::init

File

src/Plugin/ProdCheck/Modules/ModuleList.php, line 101
Contains \Drupal\prod_check\Plugin\ProdCheck\Modules\ModuleList.

Class

ModuleList
Returns a list of installed modules (and their updates).

Namespace

Drupal\prod_check\Plugin\ProdCheck\Modules

Code

public function init() {
  $build = array(
    '#theme' => 'update_report',
  );
  if (!function_exists('update_get_available')) {
    return $build;
  }
  if ($available = update_get_available(TRUE)) {
    $this->moduleHandler
      ->loadInclude('update', 'compare.inc');
    $private_key = Drupal::service('private_key')
      ->get();
    $build['#data'] = [
      'projects' => update_calculate_project_data($available),
      'site_key' => $private_key,
      'last_update' => (int) $_SERVER['REQUEST_TIME'],
    ];
    $this->moduleListRefreshed = TRUE;
    $this->moduleList = $build['#data'];
  }
  return $build;
}