Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

API-CHANGE: SSF-168 changing the API/code-conventions for excluding s…

…pecific reports. get_reports method now returns an ArrayList instead of an array of SS_Reports.
  • Loading branch information...
commit 349a04d049b454b616ca332b1f2e4fe517cbb796 1 parent ee220bb
@candidasa candidasa authored
Showing with 37 additions and 9 deletions.
  1. +24 −7 code/reports/Report.php
  2. +13 −2 tests/reports/ReportTest.php
View
31 code/reports/Report.php
@@ -147,6 +147,7 @@ function dataClass() {
* The default value is zero.
*/
static function register($list, $reportClass, $priority = 0) {
+ Deprecation::notice('3.0', 'All subclasses of SS_Report now appear in the report admin, no need to register');
}
/**
@@ -154,21 +155,37 @@ static function register($list, $reportClass, $priority = 0) {
* All subclasses of SS_Report now appear in the report admin, no need to register or unregister.
*/
static function unregister($list, $reportClass) {
- self::excludeReport($reportClass);
+ self::add_excluded_reports($reportClass);
}
/**
- * Exclude a certain report class from the list of Reports in the CMS
- * @static
- * @param $reportClass
+ * 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
*/
- static function excludeReport($reportClass) {
- self::$excluded_reports[] = $reportClass; //add to the excluded reports, so this report doesn't get used
+ static function add_excluded_reports($reportClass) {
+ if (is_array($reportClass)) {
+ self::$excluded_reports = array_merge(self::$excluded_reports, $reportClass);
+ } else {
+ if (is_string($reportClass)) {
+ //add to the excluded reports, so this report doesn't get used
+ self::$excluded_reports[] = $reportClass;
+ }
+ }
+ }
+
+
+ /**
+ * Return an array of excluded reports. That is, reports that will not be included in
+ * the list of reports in report admin in the CMS.
+ * @return array
+ */
+ static function get_excluded_reports() {
+ return self::$excluded_reports;
}
/**
* Return the SS_Report objects making up the given list.
- * @return An array of SS_Report objects
+ * @return ArrayList an arraylist of SS_Report objects
*/
static function get_reports() {
$reports = ClassInfo::subclassesFor(get_called_class());
View
15 tests/reports/ReportTest.php
@@ -20,8 +20,8 @@ function testExcludeReport() {
}
$this->assertContains('ReportTest_FakeTest',$reportNames,'ReportTest_FakeTest is in reports list');
- //excluse one report
- SS_Report::excludeReport('ReportTest_FakeTest');
+ //exclude one report
+ SS_Report::add_excluded_reports('ReportTest_FakeTest');
$reports = SS_Report::get_reports();
$reportNames = array();
@@ -29,6 +29,17 @@ function testExcludeReport() {
$reportNames[] = $report->class;
}
$this->assertNotContains('ReportTest_FakeTest',$reportNames,'ReportTest_FakeTest is NOT in reports list');
+
+ //exclude two reports
+ SS_Report::add_excluded_reports(array('ReportTest_FakeTest','ReportTest_FakeTest2'));
+
+ $reports = SS_Report::get_reports();
+ $reportNames = array();
+ foreach($reports as $report) {
+ $reportNames[] = $report->class;
+ }
+ $this->assertNotContains('ReportTest_FakeTest',$reportNames,'ReportTest_FakeTest is NOT in reports list');
+ $this->assertNotContains('ReportTest_FakeTest2',$reportNames,'ReportTest_FakeTest2 is NOT in reports list');
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.