mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
adding getCount method
the getCount method works out the number of "entries" for each report. E.g. if the report is "missing pages" and the method returns 3 then there are three "missing pages".
This commit is contained in:
parent
649bb572e5
commit
c736906016
@ -127,6 +127,7 @@ class SS_Report extends ViewableData {
|
||||
return $this->dataClass;
|
||||
}
|
||||
|
||||
|
||||
public function getLink($action = null) {
|
||||
return Controller::join_links(
|
||||
'admin/reports/',
|
||||
@ -136,6 +137,21 @@ class SS_Report extends ViewableData {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* counts the number of objects returned
|
||||
* @param Array $params - any parameters for the sourceRecords
|
||||
* @return Int
|
||||
*/
|
||||
public function getCount($params = array()){
|
||||
$sourceRecords = $this->sourceRecords($params, null, null);
|
||||
if(!$sourceRecords instanceOf SS_List){
|
||||
user_error($this->class."::sourceRecords does not return an SS_List", E_USER_NOTICE);
|
||||
return "-1";
|
||||
}
|
||||
return $sourceRecords->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude certain reports classes from the list of Reports in the CMS
|
||||
* @param $reportClass Can be either a string with the report classname or an array of reports classnames
|
||||
@ -420,4 +436,4 @@ abstract class SS_ReportWrapper extends SS_Report {
|
||||
public function canView($member = null) {
|
||||
return $this->baseReport->canView($member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user