Conditions | 1 |
Paths | 1 |
Total Lines | 64 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
38 | public function updateCMSFields(FieldList $fields) |
||
39 | { |
||
40 | $fields->insertBefore('Access', $usertab = Tab::create('UserManagement', 'User Management')); |
||
41 | $fields->addFieldToTab( |
||
42 | 'Root.UserManagement', |
||
43 | TreeDropdownField::create( |
||
44 | 'CustomerGroupID', |
||
45 | _t(__CLASS__ . '.CustomerGroup', 'Group to add new customers to'), |
||
46 | Group::class |
||
47 | ) |
||
48 | ); |
||
49 | $fields->addFieldToTab( |
||
50 | 'Root.UserManagement', |
||
51 | TreeDropdownField::create( |
||
52 | 'LoginUrlID', |
||
53 | _t(__CLASS__ . '.LoginUrl', 'Login Url'), |
||
54 | SiteTree::class |
||
55 | ) |
||
56 | ); |
||
57 | $fields->addFieldToTab( |
||
58 | 'Root.UserManagement', |
||
59 | TreeDropdownField::create( |
||
60 | 'LoginCallBackUrlID', |
||
61 | _t(__CLASS__ . '.LoginCallBackUrl', 'Login Call Back Url'), |
||
62 | SiteTree::class |
||
63 | ) |
||
64 | ); |
||
65 | $fields->addFieldToTab( |
||
66 | 'Root.UserManagement', |
||
67 | TreeDropdownField::create( |
||
68 | 'LostPasswordUrlID', |
||
69 | _t(__CLASS__ . '.LostPasswordUrl', 'Lost Password Url'), |
||
70 | SiteTree::class |
||
71 | ) |
||
72 | ); |
||
73 | $fields->addFieldToTab( |
||
74 | 'Root.UserManagement', |
||
75 | TextareaField::create( |
||
76 | 'ProfileUpdateSuccess', |
||
77 | _t(__CLASS__ . '.ProfileUpdateSuccess', 'Profile update Success Message') |
||
78 | ) |
||
79 | ); |
||
80 | $fields->addFieldToTab( |
||
81 | 'Root.UserManagement', |
||
82 | TextareaField::create( |
||
83 | 'ProfileUpdatError', |
||
84 | _t(__CLASS__ . '.ProfileUpdatError', 'Profile update Error Message') |
||
85 | ) |
||
86 | ); |
||
87 | $fields->addFieldToTab( |
||
88 | 'Root.UserManagement', |
||
89 | CheckboxField::create( |
||
90 | 'EnableSpamProtection', |
||
91 | _t(__CLASS__ . '.EnableSpamProtection', 'Enable Spam Protection') |
||
92 | ) |
||
93 | ); |
||
94 | |||
95 | $fields->addFieldToTab( |
||
96 | 'Root.UserManagement', |
||
97 | ListboxField::create( |
||
98 | 'ExportFields', |
||
99 | 'Select Data fields for the report', |
||
100 | $this->getExportFieldNames(), |
||
101 | json_decode($this->owner->ExportFields) |
||
102 | ) |
||
172 |