Skip to content

Commit

Permalink
ENH Prefer dependency injection for GridFieldComponents. (#147)
Browse files Browse the repository at this point in the history
GridFieldComponents packaged with silverstripe/framework are injectable as of 4.11.0
  • Loading branch information
GuySartorelli authored Mar 3, 2022
1 parent ede88ee commit 6d56502
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions code/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ public function getReportField()
$items = $this->sourceRecords($params, null, null);

$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldButtonRow('before'),
new GridFieldPrintButton('buttons-before-left'),
new GridFieldExportButton('buttons-before-left'),
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
new GridFieldPaginator()
GridFieldButtonRow::create('before'),
GridFieldPrintButton::create('buttons-before-left'),
GridFieldExportButton::create('buttons-before-left'),
GridFieldSortableHeader::create(),
GridFieldDataColumns::create(),
GridFieldPaginator::create()
);
/** @var GridField $gridField */
$gridField = GridField::create('Report', null, $items, $gridFieldConfig);
Expand Down
8 changes: 4 additions & 4 deletions code/ReportAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ public function getEditForm($id = null, $fields = null)
// List all reports
$fields = new FieldList();
$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
new GridFieldFooter()
GridFieldSortableHeader::create(),
GridFieldDataColumns::create(),
GridFieldFooter::create()
);
$gridField = new GridField('Reports', false, $this->Reports(), $gridFieldConfig);
$gridField = GridField::create('Reports', false, $this->Reports(), $gridFieldConfig);
/** @var GridFieldDataColumns $columns */
$columns = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
$columns->setDisplayFields(array(
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"require": {
"php": "^7.4 || ^8.0",
"silverstripe/framework": "^4.10",
"silverstripe/framework": "^4.11",
"silverstripe/admin": "^1.6@dev",
"silverstripe/versioned": "^1.6@dev",
"silverstripe/config": "^1.0@dev",
Expand Down

0 comments on commit 6d56502

Please sign in to comment.