Skip to content
Permalink
Browse files

NEW Use Injector to create new class instances and pass $params

Also adds a couple of missing PHPDoc annotations for IDE hints
  • Loading branch information...
robbieaverill authored and unclecheese committed Jul 16, 2018
1 parent ebe98f4 commit 9270206c3bd2fe35bb263ad43ad3a5d87360873a
Showing with 6 additions and 4 deletions.
  1. +6 −4 code/Report.php
@@ -164,11 +164,11 @@ public function records($params)
if ($this->hasMethod('sourceRecords')) {
return $this->sourceRecords($params, null, null);
} else {
$query = $this->sourceQuery();
$results = new ArrayList();
$query = $this->sourceQuery($params);
$results = ArrayList::create();
foreach ($query->execute() as $data) {
$class = $this->dataClass();
$result = new $class($data);
$result = Injector::inst()->create($class, $data);
$results->push($result);
}
return $results;
@@ -362,7 +362,9 @@ public function getReportField()
new GridFieldDataColumns(),
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);
$displayFields = [];
$fieldCasting = [];

0 comments on commit 9270206

Please sign in to comment.
You can’t perform that action at this time.