public function ReportTable::viewReport in Commerce Reporting 8
Views a report.
Parameters
string $report_type_id: The report type plugin ID.
string $type: The report type. valid values are week, day, or month fallback.
Return value
array The render array.
1 string reference to 'ReportTable::viewReport'
File
- src/
Controller/ ReportTable.php, line 63
Class
- ReportTable
- Table report controller.
Namespace
Drupal\commerce_reports\ControllerCode
public function viewReport($report_type_id, $type = 'month') {
if ($type == 'week') {
$date_format = 'W - Y';
}
elseif ($type == 'day') {
$date_format = 'j F Y';
}
else {
$date_format = 'F Y';
}
if (!$this->reportTypeManager
->hasDefinition($report_type_id)) {
throw new \InvalidArgumentException("Invalid report type ID for {$report_type_id}");
}
/** @var \Drupal\commerce_reports\Plugin\Commerce\ReportType\ReportTypeInterface $report_type */
$report_type = $this->reportTypeManager
->createInstance($report_type_id);
$query = $this->reportQueryBuilder
->getQuery($report_type, $date_format);
$results = $query
->execute();
return $report_type
->buildReportTable($results);
}