mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge pull request #106 from creative-commoners/pulls/4.3/injection
NEW Use Injector to create new class instances and pass $params
This commit is contained in:
commit
c90f1ed47c
@ -164,11 +164,11 @@ class Report extends ViewableData
|
|||||||
if ($this->hasMethod('sourceRecords')) {
|
if ($this->hasMethod('sourceRecords')) {
|
||||||
return $this->sourceRecords($params, null, null);
|
return $this->sourceRecords($params, null, null);
|
||||||
} else {
|
} else {
|
||||||
$query = $this->sourceQuery();
|
$query = $this->sourceQuery($params);
|
||||||
$results = new ArrayList();
|
$results = ArrayList::create();
|
||||||
foreach ($query->execute() as $data) {
|
foreach ($query->execute() as $data) {
|
||||||
$class = $this->dataClass();
|
$class = $this->dataClass();
|
||||||
$result = new $class($data);
|
$result = Injector::inst()->create($class, $data);
|
||||||
$results->push($result);
|
$results->push($result);
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
@ -362,7 +362,9 @@ class Report extends ViewableData
|
|||||||
new GridFieldDataColumns(),
|
new GridFieldDataColumns(),
|
||||||
new GridFieldPaginator()
|
new GridFieldPaginator()
|
||||||
);
|
);
|
||||||
$gridField = new GridField('Report', null, $items, $gridFieldConfig);
|
/** @var GridField $gridField */
|
||||||
|
$gridField = GridField::create('Report', null, $items, $gridFieldConfig);
|
||||||
|
/** @var GridFieldDataColumns $columns */
|
||||||
$columns = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
$columns = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
||||||
$displayFields = [];
|
$displayFields = [];
|
||||||
$fieldCasting = [];
|
$fieldCasting = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user