| Conditions | 2 |
| Paths | 2 |
| Total Lines | 68 |
| Code Lines | 42 |
| 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 |
||
| 106 | public function updateCMSFields(FieldList $fields) |
||
| 107 | { |
||
| 108 | $helpText = LiteralField::create( |
||
| 109 | 'ContentReviewHelp', |
||
| 110 | _t( |
||
| 111 | 'ContentReview.DEFAULTSETTINGSHELP', |
||
| 112 | 'These settings will apply to all pages that do not have a specific Content Review schedule.' |
||
| 113 | ) |
||
| 114 | ); |
||
| 115 | |||
| 116 | $fields->addFieldToTab('Root.ContentReview', $helpText); |
||
| 117 | |||
| 118 | $reviewFrequency = DropdownField::create( |
||
| 119 | 'ReviewPeriodDays', |
||
| 120 | _t('ContentReview.REVIEWFREQUENCY', 'Review frequency'), |
||
| 121 | SiteTreeContentReview::get_schedule() |
||
| 122 | ) |
||
| 123 | ->setDescription(_t( |
||
| 124 | 'ContentReview.REVIEWFREQUENCYDESCRIPTION', |
||
| 125 | 'The review date will be set to this far in the future, whenever the page is published.' |
||
| 126 | )); |
||
| 127 | |||
| 128 | $fields->addFieldToTab('Root.ContentReview', $reviewFrequency); |
||
| 129 | |||
| 130 | $users = Permission::get_members_by_permission(array( |
||
| 131 | 'CMS_ACCESS_CMSMain', |
||
| 132 | 'ADMIN', |
||
| 133 | )); |
||
| 134 | |||
| 135 | $usersMap = $users->map('ID', 'Title')->toArray(); |
||
| 136 | asort($usersMap); |
||
| 137 | |||
| 138 | $userField = ListboxField::create('OwnerUsers', _t('ContentReview.PAGEOWNERUSERS', 'Users'), $usersMap) |
||
| 139 | ->setAttribute('data-placeholder', _t('ContentReview.ADDUSERS', 'Add users')) |
||
| 140 | ->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews')); |
||
| 141 | |||
| 142 | $fields->addFieldToTab('Root.ContentReview', $userField); |
||
| 143 | |||
| 144 | $groupsMap = array(); |
||
| 145 | |||
| 146 | foreach (Group::get() as $group) { |
||
| 147 | // Listboxfield values are escaped, use ASCII char instead of » |
||
| 148 | $groupsMap[$group->ID] = $group->getBreadcrumbs(' > '); |
||
| 149 | } |
||
| 150 | |||
| 151 | asort($groupsMap); |
||
| 152 | |||
| 153 | $groupField = ListboxField::create('OwnerGroups', _t('ContentReview.PAGEOWNERGROUPS', 'Groups'), $groupsMap) |
||
| 154 | ->setAttribute('data-placeholder', _t('ContentReview.ADDGROUP', 'Add groups')) |
||
| 155 | ->setDescription(_t('ContentReview.OWNERGROUPSDESCRIPTION', 'Page owners that are responsible for reviews')); |
||
| 156 | |||
| 157 | $fields->addFieldToTab('Root.ContentReview', $groupField); |
||
| 158 | |||
| 159 | // Email content |
||
| 160 | $fields->addFieldsToTab( |
||
| 161 | 'Root.ContentReview', |
||
| 162 | array( |
||
| 163 | TextField::create('ReviewFrom', _t('ContentReview.EMAILFROM', 'From email address')) |
||
| 164 | ->setDescription(_t('Review.EMAILFROM_RIGHTTITLE', 'e.g: [email protected]')), |
||
| 165 | TextField::create('ReviewSubject', _t('ContentReview.EMAILSUBJECT', 'Subject line')), |
||
| 166 | TextAreaField::create('ReviewBody', _t('ContentReview.EMAILTEMPLATE', 'Email template')), |
||
| 167 | LiteralField::create( |
||
| 168 | 'TemplateHelp', |
||
| 169 | $this->owner->renderWith('SilverStripe\\ContentReview\\ContentReviewAdminHelp') |
||
| 170 | ), |
||
| 171 | ) |
||
| 172 | ); |
||
| 173 | } |
||
| 174 | |||
| 242 |
This check marks private properties in classes that are never used. Those properties can be removed.