mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
NEW Extracting out the method to determine parameters (filters) for update the report sourceRecords
This commit is contained in:
parent
d6b1c071b6
commit
52a234410d
@ -346,12 +346,7 @@ class Report extends ViewableData
|
||||
*/
|
||||
public function getReportField()
|
||||
{
|
||||
$params = [];
|
||||
if (Injector::inst()->has(HTTPRequest::class)) {
|
||||
/** @var HTTPRequest $request */
|
||||
$request = Injector::inst()->get(HTTPRequest::class);
|
||||
$params = $request->param('filters') ?: $request->requestVar('filters') ?: [];
|
||||
}
|
||||
$params = $this->getSourceParams();
|
||||
$items = $this->sourceRecords($params, null, null);
|
||||
|
||||
$gridFieldConfig = GridFieldConfig::create()->addComponents(
|
||||
@ -484,4 +479,23 @@ class Report extends ViewableData
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get source params for the report to filter by
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getSourceParams()
|
||||
{
|
||||
$params = [];
|
||||
if (Injector::inst()->has(HTTPRequest::class)) {
|
||||
/** @var HTTPRequest $request */
|
||||
$request = Injector::inst()->get(HTTPRequest::class);
|
||||
$params = $request->param('filters') ?: $request->requestVar('filters') ?: [];
|
||||
}
|
||||
|
||||
$this->extend('updateSourceParams', $params);
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user