ENH Prefer dependency injection for GridFieldComponents. (#147)

GridFieldComponents packaged with silverstripe/framework are injectable as of 4.11.0
This commit is contained in:
Guy Sartorelli 2022-03-04 10:13:45 +13:00 committed by GitHub
parent ede88ee491
commit 6d565028c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View File

@ -389,12 +389,12 @@ class Report extends ViewableData
$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);

View File

@ -230,11 +230,11 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider
// 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(

View File

@ -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",