From ab81961115f2ec19d1e54608263e354b836d27a5 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 16 Jun 2016 17:06:51 +1200 Subject: [PATCH] API Apply SilverStripe\ORM namespace --- code/Report.php | 82 +++++++++++++++++++++++--------------------- code/ReportAdmin.php | 23 +++++++------ tests/ReportTest.php | 4 ++- 3 files changed, 59 insertions(+), 50 deletions(-) diff --git a/code/Report.php b/code/Report.php index b8e8f298..a4399596 100644 --- a/code/Report.php +++ b/code/Report.php @@ -1,32 +1,36 @@ title; } - + /** * Allows access to title as a property - * + * * @return string */ public function getTitle() { return $this->title(); } - + /** * Return the description of this report. - * + * * You have two ways of specifying the description: - * - overriding description(), which lets you support i18n + * - overriding description(), which lets you support i18n * - defining the $description property */ public function description() { return $this->description; } - + /** * Return the {@link SQLQuery} that provides your report data. */ @@ -121,7 +125,7 @@ class SS_Report extends ViewableData user_error("Please override sourceQuery()/sourceRecords() and columns() or, if necessary, override getReportField()", E_USER_ERROR); } } - + /** * Return a SS_List records for this report. */ @@ -261,11 +265,11 @@ class SS_Report extends ViewableData if($title = $this->title()) { $fields->push(new LiteralField('ReportTitle', "

{$title}

")); } - + if($description = $this->description()) { $fields->push(new LiteralField('ReportDescription', "

" . $description . "

")); } - + // Add search fields is available if($this->hasMethod('parameterFields') && $parameterFields = $this->parameterFields()) { foreach($parameterFields as $field) { @@ -278,14 +282,14 @@ class SS_Report extends ViewableData // Add a search button $fields->push(new FormAction('updatereport', _t('GridField.Filter'))); } - + $fields->push($this->getReportField()); $this->extend('updateCMSFields', $fields); - + return $fields; } - + public function getCMSActions() { // getCMSActions() can be extended with updateCMSActions() on a extension @@ -293,11 +297,11 @@ class SS_Report extends ViewableData $this->extend('updateCMSActions', $actions); return $actions; } - + /** * Return a field, such as a {@link GridField} that is * used to show and manipulate data relating to this report. - * + * * Generally, you should override {@link columns()} and {@link records()} to make your report, * but if they aren't sufficiently flexible, then you can override this method. * @@ -329,7 +333,7 @@ class SS_Report extends ViewableData if (is_string($info)) { $info = array('title' => $info); } - + if (isset($info['formatting'])) { $fieldFormatting[$source] = $info['formatting']; } @@ -353,7 +357,7 @@ class SS_Report extends ViewableData return $gridField; } - + /** * @param Member $member * @return boolean @@ -363,7 +367,7 @@ class SS_Report extends ViewableData if (!$member && $member !== false) { $member = Member::currentUser(); } - + $extended = $this->extendedCan('canView', $member); if($extended !== null) { return $extended; @@ -372,7 +376,7 @@ class SS_Report extends ViewableData if($member && Permission::checkMember($member, array('CMS_ACCESS_LeftAndMain', 'CMS_ACCESS_ReportAdmin'))) { return true; } - + return false; } @@ -396,7 +400,7 @@ class SS_Report extends ViewableData } return null; } - + /** * Return the name of this report, which @@ -414,17 +418,17 @@ class SS_Report extends ViewableData /** * SS_ReportWrapper is a base class for creating report wappers. - * + * * Wrappers encapsulate an existing report to alter their behaviour - they are implementations of * the standard GoF decorator pattern. - * + * * This base class ensure that, by default, wrappers behave in the same way as the report that is * being wrapped. You should override any methods that need to behave differently in your subclass * of SS_ReportWrapper. - * + * * It also makes calls to 2 empty methods that you can override {@link beforeQuery()} and * {@link afterQuery()} - * + * * @package reports */ abstract class SS_ReportWrapper extends SS_Report @@ -507,12 +511,12 @@ abstract class SS_ReportWrapper extends SS_Report { return $this->baseReport->title(); } - + public function group() { return $this->baseReport->hasMethod('group') ? $this->baseReport->group() : 'Group'; } - + public function sort() { return $this->baseReport->hasMethod('sort') ? $this->baseReport->sort() : 0; @@ -526,5 +530,5 @@ abstract class SS_ReportWrapper extends SS_Report public function canView($member = null) { return $this->baseReport->canView($member); - } + } } diff --git a/code/ReportAdmin.php b/code/ReportAdmin.php index 430aad4a..01fdfc2f 100644 --- a/code/ReportAdmin.php +++ b/code/ReportAdmin.php @@ -1,24 +1,27 @@ Link = singleton('ReportAdmin')->Link(); diff --git a/tests/ReportTest.php b/tests/ReportTest.php index 7a3b00f1..be1c651e 100644 --- a/tests/ReportTest.php +++ b/tests/ReportTest.php @@ -1,5 +1,7 @@