You are here

public function PerfmonController::mainPage in Performance monitor 8

Main perform results page callback.

1 string reference to 'PerfmonController::mainPage'
perfmon.routing.yml in ./perfmon.routing.yml
perfmon.routing.yml

File

src/Controller/PerfmonController.php, line 12

Class

PerfmonController

Namespace

Drupal\perfmon\Controller

Code

public function mainPage() {
  $output = array();

  // Retrieve the testlist.
  $testlist = perfmon_get_testlist();

  // Retrieve results from last run of the testlist.
  $tests = perfmon_get_stored_results();

  // Only users with the proper permission can run the testlist.
  if (\Drupal::currentUser()
    ->hasPermission('run performance monitor checks')) {
    $output += \Drupal::formBuilder()
      ->getForm('Drupal\\perfmon\\Form\\PerfmonRunForm', $tests);
  }
  if (!empty($tests)) {

    // We have prior results, so display them.
    $output['results'] = perfmon_reviewed($testlist, $tests);
  }
  else {

    // If they haven't configured the site, prompt them to do so.
    \Drupal::messenger()
      ->addStatus($this
      ->t('It appears this is your first time using the performance testlist.'));
  }
  return $output;
}