| Conditions | 4 |
| Paths | 6 |
| Total Lines | 87 |
| Code Lines | 59 |
| 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['lib'] = $task->getLib(); |
||
| 46 | $taskInfo['pid'] = $task->getPid(); |
||
| 47 | $taskInfo['solr'] = $task->getSolr(); |
||
| 48 | $taskInfo['from'] = $task->getFrom(); |
||
| 49 | $taskInfo['until'] = $task->getUntil(); |
||
| 50 | $taskInfo['set'] = $task->getSet(); |
||
| 51 | } else { |
||
| 52 | $taskInfo['dryRun'] = false; |
||
| 53 | $taskInfo['lib'] = - 1; |
||
| 54 | $taskInfo['pid'] = - 1; |
||
| 55 | $taskInfo['solr'] = - 1; |
||
| 56 | $taskInfo['from'] = ''; |
||
| 57 | $taskInfo['until'] = ''; |
||
| 58 | $taskInfo['set'] = ''; |
||
| 59 | } |
||
| 60 | |||
| 61 | $additionalFields = []; |
||
| 62 | |||
| 63 | // Checkbox for dry-run |
||
| 64 | $additionalFields['dryRun'] = $this->getDryRunField($taskInfo['dryRun']); |
||
| 65 | |||
| 66 | // Text field for library |
||
| 67 | $fieldName = 'lib'; |
||
| 68 | $fieldId = 'task_' . $fieldName; |
||
| 69 | |||
| 70 | $allLibraries = $this->getLibraries($taskInfo['pid']); |
||
| 71 | $options = []; |
||
| 72 | $options[] = '<option value="-1"></option>'; |
||
| 73 | foreach ($allLibraries as $label => $uid) { |
||
| 74 | $options[] = '<option value="' . $uid . '" ' . ($taskInfo['lib'] == $uid ? 'selected' : '') . ' >' . $label . '</option>'; |
||
| 75 | } |
||
| 76 | |||
| 77 | $fieldHtml = '<select name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '">' . implode("\n", $options) . '</select>'; |
||
| 78 | $additionalFields[$fieldId] = [ |
||
| 79 | 'code' => $fieldHtml, |
||
| 80 | 'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.lib', |
||
| 81 | 'cshKey' => '_MOD_system_txschedulerM1', |
||
| 82 | 'cshLabel' => $fieldId |
||
| 83 | ]; |
||
| 84 | |||
| 85 | // DropDown for Pid |
||
| 86 | $additionalFields['pid'] = $this->getPidField($taskInfo['pid']); |
||
| 87 | |||
| 88 | // DropDown for Solr core |
||
| 89 | $additionalFields['solr'] = $this->getSolrField($taskInfo['solr'], $taskInfo['pid']); |
||
| 90 | |||
| 91 | // Text field for from |
||
| 92 | $fieldName = 'from'; |
||
| 93 | $fieldId = 'task_' . $fieldName; |
||
| 94 | $fieldHtml = '<input type="date" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="' . $taskInfo[$fieldName] . '" >'; |
||
| 95 | $additionalFields[$fieldId] = [ |
||
| 96 | 'code' => $fieldHtml, |
||
| 97 | 'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.from', |
||
| 98 | 'cshKey' => '_MOD_system_txschedulerM1', |
||
| 99 | 'cshLabel' => $fieldId |
||
| 100 | ]; |
||
| 101 | |||
| 102 | // Text field for until |
||
| 103 | $fieldName = 'until'; |
||
| 104 | $fieldId = 'task_' . $fieldName; |
||
| 105 | $fieldHtml = '<input type="date" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="' . $taskInfo[$fieldName] . '" >'; |
||
| 106 | $additionalFields[$fieldId] = [ |
||
| 107 | 'code' => $fieldHtml, |
||
| 108 | 'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.until', |
||
| 109 | 'cshKey' => '_MOD_system_txschedulerM1', |
||
| 110 | 'cshLabel' => $fieldId |
||
| 111 | ]; |
||
| 112 | |||
| 113 | // Text field for set |
||
| 114 | $fieldName = 'set'; |
||
| 115 | $fieldId = 'task_' . $fieldName; |
||
| 116 | $fieldHtml = '<input type="text" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="' . $taskInfo[$fieldName] . '" >'; |
||
| 117 | $additionalFields[$fieldId] = [ |
||
| 118 | 'code' => $fieldHtml, |
||
| 119 | 'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.set', |
||
| 120 | 'cshKey' => '_MOD_system_txschedulerM1', |
||
| 121 | 'cshLabel' => $fieldId |
||
| 122 | ]; |
||
| 123 | |||
| 124 | return $additionalFields; |
||
| 125 | } |
||
| 156 |