protected function DaysOfWeek::_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 DaysOfWeek::_getData()
- DaysOfWeek::display in src/
Controller/ Report/ DaysOfWeek.php - Returns a days of week page page.
File
- src/
Controller/ Report/ DaysOfWeek.php, line 129 - Contains Drupal\visitors\Controller\Report\DaysOfWeek.
Class
Namespace
Drupal\visitors\Controller\ReportCode
protected function _getData($header) {
$query = \Drupal::database()
->select('visitors', 'v');
$query
->addExpression('COUNT(*)', 'count');
$query
->addExpression(visitors_date_format_sql('visitors_date_time', '%a'), 'd');
$query
->addExpression(visitors_date_format_sql('MIN(visitors_date_time)', '%w'), 'n');
visitors_date_filter_sql_condition($query);
$query
->groupBy('d');
$query
->orderBy('n');
$results = $query
->execute();
$rows = array();
$i = 0;
$tmp_rows = array();
foreach ($results as $data) {
$tmp_rows[$data->n] = array(
$data->d,
$data->count,
$data->n,
);
}
$sort_days = $this
->_getDaysOfWeek();
foreach ($sort_days as $day => $value) {
$rows[$value] = array(
$value,
t($day),
0,
);
}
foreach ($tmp_rows as $tmp_item) {
$day_of_week = Unicode::ucfirst(mb_strtolower($tmp_item[0]));
$rows[$sort_days[$day_of_week]][2] = $tmp_item[1];
}
return $rows;
}