You are here

public function Hours::display in Visitors 8.2

Returns a hours page.

Return value

array A render array representing the hours page content.

1 string reference to 'Hours::display'
visitors.routing.yml in ./visitors.routing.yml
visitors.routing.yml

File

src/Controller/Report/Hours.php, line 61
Contains Drupal\visitors\Controller\Report\Hours.

Class

Hours

Namespace

Drupal\visitors\Controller\Report

Code

public function display() {
  $config = \Drupal::config('visitors.config');
  $form = $this->formBuilder
    ->getForm('Drupal\\visitors\\Form\\DateFilter');
  $header = $this
    ->_getHeader();
  $results = $this
    ->_getData(NULL);
  $tmp_rows = array();
  $y = array();
  for ($i = 0; $i < 24; $i++) {
    $y[$i] = 0;
  }
  foreach ($results as $data) {
    $y[(int) $data[1]] = $data[2];
  }
  return array(
    'visitors_date_filter_form' => $form,
    'visitors_jqplot' => array(
      '#theme' => 'visitors_jqplot',
      '#path' => drupal_get_path('module', 'visitors'),
      '#x' => implode(', ', range(0, 23)),
      '#y' => implode(', ', $y),
      '#width' => $config
        ->get('chart_width'),
      '#height' => $config
        ->get('chart_height'),
    ),
    'visitors_table' => array(
      '#type' => 'table',
      '#header' => $header,
      '#rows' => $this
        ->_getData($header),
    ),
  );
}