You are here

protected function DaysOfMonth::_getData in Visitors 8.2

Returns a table content.

Parameters

array $header: Table header configuration.

Return value

array Array representing the table content.

1 call to DaysOfMonth::_getData()
DaysOfMonth::display in src/Controller/Report/DaysOfMonth.php
Returns a days of month page.

File

src/Controller/Report/DaysOfMonth.php, line 131
Contains Drupal\visitors\Controller\Report\DaysOfMonth.

Class

DaysOfMonth

Namespace

Drupal\visitors\Controller\Report

Code

protected function _getData($header) {
  $query = \Drupal::database()
    ->select('visitors', 'v');
  $query
    ->addExpression('COUNT(*)', 'count');
  $query
    ->addExpression(visitors_date_format_sql('visitors_date_time', '%d'), 'day');
  $query
    ->groupBy('day');
  visitors_date_filter_sql_condition($query);
  if (!is_null($header)) {
    $query
      ->extend('Drupal\\Core\\Database\\Query\\TableSortExtender')
      ->orderByHeader($header);
  }
  $results = $query
    ->execute();
  $rows = array();
  $i = 0;
  foreach ($results as $data) {
    $rows[] = array(
      ++$i,
      (int) $data->day,
      $data->count,
    );
  }
  return $rows;
}