Merge pull request #154 from creative-commoners/pulls/4/rescue-master-psr12

Rescue Master Branch PR: PSR12 compliance
This commit is contained in:
Steve Boyd 2022-08-29 18:15:29 +12:00 committed by GitHub
commit bd74939c14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 27 additions and 26 deletions

View File

@ -61,7 +61,8 @@ use SilverStripe\View\ViewableData;
* Right now, all subclasses of SS_Report will be shown in the ReportAdmin. In SS3 there is only * Right now, all subclasses of SS_Report will be shown in the ReportAdmin. In SS3 there is only
* one place where reports can go, so this class is greatly simplifed from its version in SS2. * one place where reports can go, so this class is greatly simplifed from its version in SS2.
* *
* @method SS_List|DataList sourceRecords($params = [], $sort = null, $limit = null) List of records to show for this report * @method SS_List|DataList sourceRecords($params = [], $sort = null, $limit = null)
* List of records to show for this report
*/ */
class Report extends ViewableData class Report extends ViewableData
{ {
@ -158,7 +159,8 @@ class Report extends ViewableData
{ {
if (!$this->hasMethod('sourceRecords')) { if (!$this->hasMethod('sourceRecords')) {
throw new \RuntimeException( throw new \RuntimeException(
'Please override sourceQuery()/sourceRecords() and columns() or, if necessary, override getReportField()' 'Please override sourceQuery()/sourceRecords() and columns() or, '
. 'if necessary, override getReportField()'
); );
} }
@ -353,7 +355,10 @@ class Report extends ViewableData
} }
// Add a search button // Add a search button
$formAction = FormAction::create('updatereport', _t('SilverStripe\\Forms\\GridField\\GridField.Filter', 'Filter')); $formAction = FormAction::create(
'updatereport',
_t('SilverStripe\\Forms\\GridField\\GridField.Filter', 'Filter')
);
$formAction->addExtraClass('btn-primary mb-4'); $formAction->addExtraClass('btn-primary mb-4');
$fields->push($formAction); $fields->push($formAction);

View File

@ -181,13 +181,13 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
} }
//build breadcrumb trail to the current report //build breadcrumb trail to the current report
$items->push(new ArrayData(array( $items->push(ArrayData::create([
'Title' => $report->title(), 'Title' => $report->title(),
'Link' => Controller::join_links( 'Link' => Controller::join_links(
$this->Link(), $this->Link(),
'?' . http_build_query(array('q' => $this->request->requestVar('q'))) '?' . http_build_query(['q' => $this->request->requestVar('q')])
) )
))); ]));
} }
return $items; return $items;
@ -236,7 +236,8 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
); );
$gridField = GridField::create('Reports', false, $this->Reports(), $gridFieldConfig); $gridField = GridField::create('Reports', false, $this->Reports(), $gridFieldConfig);
/** @var GridFieldDataColumns $columns */ /** @var GridFieldDataColumns $columns */
$columns = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns'); $columns = $gridField->getConfig()
->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
$columns->setDisplayFields(array( $columns->setDisplayFields(array(
'title' => _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title'), 'title' => _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title'),
)); ));
@ -250,7 +251,9 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
$actions = new FieldList(); $actions = new FieldList();
$form = new Form($this, "EditForm", $fields, $actions); $form = new Form($this, "EditForm", $fields, $actions);
$form->addExtraClass('panel panel--padded panel--scrollable cms-edit-form cms-panel-padded' . $this->BaseCSSClasses()); $form->addExtraClass(
'panel panel--padded panel--scrollable cms-edit-form cms-panel-padded' . $this->BaseCSSClasses()
);
$form->loadDataFrom($this->request->getVars()); $form->loadDataFrom($this->request->getVars());
$this->extend('updateEditForm', $form); $this->extend('updateEditForm', $form);

View File

@ -2,6 +2,8 @@
namespace SilverStripe\Reports; namespace SilverStripe\Reports;
use SilverStripe\Core\Injector\Injector;
/** /**
* SS_ReportWrapper is a base class for creating report wappers. * SS_ReportWrapper is a base class for creating report wappers.
* *
@ -21,7 +23,7 @@ abstract class ReportWrapper extends Report
public function __construct($baseReport) public function __construct($baseReport)
{ {
$this->baseReport = is_string($baseReport) ? new $baseReport : $baseReport; $this->baseReport = is_string($baseReport) ? Injector::inst()->create($baseReport) : $baseReport;
$this->dataClass = $this->baseReport->dataClass(); $this->dataClass = $this->baseReport->dataClass();
parent::__construct(); parent::__construct();
} }

View File

@ -11,8 +11,8 @@ use SilverStripe\View\ViewableData;
*/ */
class SideReportView extends ViewableData class SideReportView extends ViewableData
{ {
protected $controller;
protected $controller, $report; protected $report;
protected $parameters; protected $parameters;
public function __construct($controller, $report) public function __construct($controller, $report)

View File

@ -5,20 +5,9 @@
<file>code</file> <file>code</file>
<file>tests</file> <file>tests</file>
<!-- base rules are PSR-2 --> <!-- base rules are PSR-12 -->
<rule ref="PSR2" > <rule ref="PSR12" >
<!-- Current exclusions --> <!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" /> <exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
<exclude name="PSR2.Classes.PropertyDeclaration" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration" /> <!-- causes php notice while linting -->
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenerdefault" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment" />
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<exclude name="Squiz.Scope.MethodScope" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="PEAR.Functions.ValidDefaultValue.NotAtEnd" />
</rule> </rule>
</ruleset> </ruleset>

View File

@ -1,4 +1,5 @@
<?php <?php
namespace SilverStripe\Reports\Tests; namespace SilverStripe\Reports\Tests;
use ReflectionClass; use ReflectionClass;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace SilverStripe\Reports\Tests\ReportAdminTest; namespace SilverStripe\Reports\Tests\ReportAdminTest;
use SilverStripe\Dev\TestOnly; use SilverStripe\Dev\TestOnly;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace SilverStripe\Reports\Tests\ReportAdminTest; namespace SilverStripe\Reports\Tests\ReportAdminTest;
use SilverStripe\Control\Controller; use SilverStripe\Control\Controller;

View File

@ -8,7 +8,6 @@ use SilverStripe\Reports\Report;
abstract class FakeTestAbstract extends Report implements TestOnly abstract class FakeTestAbstract extends Report implements TestOnly
{ {
public function title() public function title()
{ {
return 'Report title Abstract'; return 'Report title Abstract';