Skip to content

Commit

Permalink
Merge branch '4' into 5
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Aug 31, 2022
2 parents 050c683 + bd74939 commit da1a148
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 26 deletions.
11 changes: 8 additions & 3 deletions code/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
* 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.
*
* @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
{
Expand Down Expand Up @@ -158,7 +159,8 @@ public function sourceQuery($params)
{
if (!$this->hasMethod('sourceRecords')) {
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()'
);
}

Expand Down Expand Up @@ -353,7 +355,10 @@ public function getCMSFields()
}

// 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');

$fields->push($formAction);
Expand Down
13 changes: 8 additions & 5 deletions code/ReportAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ public function Breadcrumbs($unlinked = false)
}

//build breadcrumb trail to the current report
$items->push(new ArrayData(array(
$items->push(ArrayData::create([
'Title' => $report->title(),
'Link' => Controller::join_links(
$this->Link(),
'?' . http_build_query(array('q' => $this->request->requestVar('q')))
'?' . http_build_query(['q' => $this->request->requestVar('q')])
)
)));
]));
}

return $items;
Expand Down Expand Up @@ -236,7 +236,8 @@ public function getEditForm($id = null, $fields = null)
);
$gridField = GridField::create('Reports', false, $this->Reports(), $gridFieldConfig);
/** @var GridFieldDataColumns $columns */
$columns = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
$columns = $gridField->getConfig()
->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
$columns->setDisplayFields(array(
'title' => _t('SilverStripe\\Reports\\ReportAdmin.ReportTitle', 'Title'),
));
Expand All @@ -250,7 +251,9 @@ public function getEditForm($id = null, $fields = null)

$actions = new FieldList();
$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());

$this->extend('updateEditForm', $form);
Expand Down
4 changes: 3 additions & 1 deletion code/ReportWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace SilverStripe\Reports;

use SilverStripe\Core\Injector\Injector;

/**
* SS_ReportWrapper is a base class for creating report wappers.
*
Expand All @@ -21,7 +23,7 @@ abstract class ReportWrapper extends Report

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();
parent::__construct();
}
Expand Down
4 changes: 2 additions & 2 deletions code/SideReportView.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*/
class SideReportView extends ViewableData
{

protected $controller, $report;
protected $controller;
protected $report;
protected $parameters;

public function __construct($controller, $report)
Expand Down
17 changes: 3 additions & 14 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
<file>code</file>
<file>tests</file>

<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- base rules are PSR-12 -->
<rule ref="PSR12" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<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" />
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
</rule>
</ruleset>
1 change: 1 addition & 0 deletions tests/ReportAdminTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace SilverStripe\Reports\Tests;

use ReflectionClass;
Expand Down
1 change: 1 addition & 0 deletions tests/ReportAdminTest/FakeReport.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace SilverStripe\Reports\Tests\ReportAdminTest;

use SilverStripe\Dev\TestOnly;
Expand Down
1 change: 1 addition & 0 deletions tests/ReportAdminTest/FakeReport2.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace SilverStripe\Reports\Tests\ReportAdminTest;

use SilverStripe\Control\Controller;
Expand Down
1 change: 0 additions & 1 deletion tests/ReportTest/FakeTestAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

abstract class FakeTestAbstract extends Report implements TestOnly
{

public function title()
{
return 'Report title Abstract';
Expand Down

0 comments on commit da1a148

Please sign in to comment.