| Conditions | 3 |
| Paths | 4 |
| Total Lines | 61 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule) |
||
| 39 | { |
||
| 40 | $currentSchedulerModuleAction = $schedulerModule->getCurrentAction(); |
||
| 41 | |||
| 42 | /** @var BaseTask $task */ |
||
| 43 | if ($currentSchedulerModuleAction->equals(Action::EDIT)) { |
||
| 44 | $taskInfo['dryRun'] = $task->isDryRun(); |
||
| 45 | $taskInfo['coll'] = $task->getColl(); |
||
| 46 | $taskInfo['pid'] = $task->getPid(); |
||
| 47 | $taskInfo['solr'] = $task->getSolr(); |
||
| 48 | $taskInfo['owner'] = $task->getOwner(); |
||
| 49 | $taskInfo['all'] = $task->isAll(); |
||
| 50 | } else { |
||
| 51 | $taskInfo['dryRun'] = false; |
||
| 52 | $taskInfo['coll'] = []; |
||
| 53 | $taskInfo['pid'] = - 1; |
||
| 54 | $taskInfo['solr'] = - 1; |
||
| 55 | $taskInfo['owner'] = ''; |
||
| 56 | $taskInfo['all'] = false; |
||
| 57 | } |
||
| 58 | |||
| 59 | $additionalFields = []; |
||
| 60 | |||
| 61 | // Checkbox for dry-run |
||
| 62 | $additionalFields['dryRun'] = $this->getDryRunField($taskInfo['dryRun']); |
||
| 63 | |||
| 64 | // Select for collection(s) |
||
| 65 | $fieldName = 'coll'; |
||
| 66 | $fieldId = 'task_' . $fieldName; |
||
| 67 | $options = $this->getCollOptions($taskInfo['coll'], $taskInfo['pid']); |
||
| 68 | ; |
||
| 69 | $fieldHtml = '<select name="tx_scheduler[' . $fieldName . '][]" id="' . $fieldId . '" size="10" multiple="multiple">' . implode("\n", $options) . '</select>'; |
||
| 70 | $additionalFields[$fieldId] = [ |
||
| 71 | 'code' => $fieldHtml, |
||
| 72 | 'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.coll', |
||
| 73 | 'cshKey' => '_MOD_system_txschedulerM1', |
||
| 74 | 'cshLabel' => $fieldId |
||
| 75 | ]; |
||
| 76 | |||
| 77 | // DropDown for storage page |
||
| 78 | $additionalFields['pid'] = $this->getPidField($taskInfo['pid']); |
||
| 79 | |||
| 80 | // DropDown for Solr core |
||
| 81 | $additionalFields['solr'] = $this->getSolrField($taskInfo['solr'], $taskInfo['pid']); |
||
| 82 | |||
| 83 | // Text field for owner |
||
| 84 | $additionalFields['owner'] = $this->getOwnerField($taskInfo['owner']); |
||
| 85 | |||
| 86 | // Checkbox for all |
||
| 87 | $fieldName = 'all'; |
||
| 88 | $fieldId = 'task_' . $fieldName; |
||
| 89 | $fieldHtml = '<input type="checkbox" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="1"' . |
||
| 90 | ($taskInfo['all'] ? ' checked="checked"' : '') . '>'; |
||
| 91 | $additionalFields[$fieldId] = [ |
||
| 92 | 'code' => $fieldHtml, |
||
| 93 | 'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.all', |
||
| 94 | 'cshKey' => '_MOD_system_txschedulerM1', |
||
| 95 | 'cshLabel' => $fieldId |
||
| 96 | ]; |
||
| 97 | |||
| 98 | return $additionalFields; |
||
| 99 | } |
||
| 148 |