From e98f0d45af1f3684748a1a49d47d0f91f2bc0225 Mon Sep 17 00:00:00 2001 From: Bernard Hamlin <948122+blueo@users.noreply.github.com> Date: Thu, 25 May 2023 11:42:43 +1200 Subject: [PATCH] Use ::create instead of new in GridFieldDetailForm_ItemRequest (#10791) Updates instances of `new X` to `X::create` so that Silverstripe classes will respect dependency injection --- .../GridField/GridFieldDetailForm_ItemRequest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php b/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php index 1191cc99d2d..f08ee32b63e 100644 --- a/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php +++ b/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php @@ -137,7 +137,7 @@ public function view($request) $form = $this->ItemEditForm(); $form->makeReadonly(); - $data = new ArrayData([ + $data = ArrayData::create([ 'Backlink' => $controller->Link(), 'ItemEditForm' => $form ]); @@ -235,7 +235,7 @@ public function ItemEditForm() } } - $form = new Form( + $form = Form::create( $this, 'ItemEditForm', $fields, @@ -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)); } } @@ -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 ]));