From 3fbccea2ea5e6808d4fc48afbf662be910e49f8a Mon Sep 17 00:00:00 2001 From: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Mon, 31 May 2021 13:00:31 +1200 Subject: [PATCH] ENH Avoid use of 'new' keyword on injectable classes from this module. It's not uncommon to want to override or enhance some functionality in vendor code that doesn't have extension points, so we should avoid the `new` keyword when instantiating injectable classes from the module. --- code/Form/UserForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/Form/UserForm.php b/code/Form/UserForm.php index d6a2c1b..c9ecf5d 100644 --- a/code/Form/UserForm.php +++ b/code/Form/UserForm.php @@ -118,7 +118,7 @@ class UserForm extends Form */ public function getFormFields() { - $fields = new UserFormsFieldList(); + $fields = UserFormsFieldList::create(); $target = $fields; foreach ($this->controller->data()->Fields() as $field) { @@ -174,7 +174,7 @@ class UserForm extends Form ->filter('Required', true) ->column('Name'); $requiredNames = array_merge($requiredNames, $this->getEmailRecipientRequiredFields()); - $required = new UserFormsRequiredFields($requiredNames); + $required = UserFormsRequiredFields::create($requiredNames); $this->extend('updateRequiredFields', $required); $required->setForm($this); return $required;