Skip to content

Commit

Permalink
Use ::create instead of new in GridFieldDetailForm_ItemRequest (#10791)
Browse files Browse the repository at this point in the history
Updates instances of `new X` to `X::create` so that Silverstripe classes will respect dependency injection
  • Loading branch information
blueo authored May 24, 2023
1 parent e8bde0f commit e98f0d4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Forms/GridField/GridFieldDetailForm_ItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function view($request)
$form = $this->ItemEditForm();
$form->makeReadonly();

$data = new ArrayData([
$data = ArrayData::create([
'Backlink' => $controller->Link(),
'ItemEditForm' => $form
]);
Expand Down Expand Up @@ -235,7 +235,7 @@ public function ItemEditForm()
}
}

$form = new Form(
$form = Form::create(
$this,
'ItemEditForm',
$fields,
Expand Down Expand Up @@ -434,7 +434,7 @@ protected function getFormActions()
$oneLevelUp->Link, // url
_t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.CancelBtn', 'Cancel') // label
);
$actions->insertAfter('MajorActions', new LiteralField('cancelbutton', $text));
$actions->insertAfter('MajorActions', LiteralField::create('cancelbutton', $text));
}
}

Expand Down Expand Up @@ -879,17 +879,17 @@ public function Breadcrumbs($unlinked = false)
$items = $this->popupController->Breadcrumbs($unlinked);

if (!$items) {
$items = new ArrayList();
$items = ArrayList::create();
}

if ($this->record && $this->record->ID) {
$title = ($this->record->Title) ? $this->record->Title : "#{$this->record->ID}";
$items->push(new ArrayData([
$items->push(ArrayData::create([
'Title' => $title,
'Link' => $this->Link()
]));
} else {
$items->push(new ArrayData([
$items->push(ArrayData::create([
'Title' => _t('SilverStripe\\Forms\\GridField\\GridField.NewRecord', 'New {type}', ['type' => $this->record->i18n_singular_name()]),
'Link' => false
]));
Expand Down

0 comments on commit e98f0d4

Please sign in to comment.