diff --git a/code/reports/Report.php b/code/reports/Report.php index 5c7862d0..e3ab707c 100644 --- a/code/reports/Report.php +++ b/code/reports/Report.php @@ -147,6 +147,7 @@ class SS_Report extends ViewableData { * 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 @@ class SS_Report extends ViewableData { * 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()); diff --git a/tests/reports/ReportTest.php b/tests/reports/ReportTest.php index 16bc3bed..c668dc66 100644 --- a/tests/reports/ReportTest.php +++ b/tests/reports/ReportTest.php @@ -20,8 +20,8 @@ class ReportTest extends SapphireTest { } $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 @@ class ReportTest extends SapphireTest { $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'); } }