Conditions | 10 |
Paths | 14 |
Total Lines | 64 |
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 |
||
62 | public function renderForeignRecordHeaderControl_postProcess( |
||
63 | $parentUid, |
||
64 | $foreignTable, |
||
65 | array $childRecord, |
||
66 | array $childConfig, |
||
67 | $isVirtual, |
||
68 | array &$controlItems |
||
69 | ) { |
||
70 | if ('sys_file_reference' !== $foreignTable) { |
||
71 | return; |
||
72 | } |
||
73 | |||
74 | if (\is_array($childRecord['uid_local'])) { |
||
75 | // Handling for TYPO3 > 8.x |
||
76 | foreach ($childRecord['uid_local'] as $item) { |
||
77 | if ('sys_file' !== $item['table']) { |
||
78 | return; |
||
79 | } |
||
80 | if (!MathUtility::canBeInterpretedAsInteger($childRecord['uid'])) { |
||
81 | return; |
||
82 | } |
||
83 | } |
||
84 | } else { |
||
85 | // Handling for TYPO3 < 8.x |
||
86 | if (!GeneralUtility::isFirstPartOfStr($childRecord['uid_local'], 'sys_file_')) { |
||
87 | return; |
||
88 | } |
||
89 | |||
90 | $parts = BackendUtility::splitTable_Uid($childRecord['uid_local']); |
||
91 | if (!isset($parts[1])) { |
||
92 | return; |
||
93 | } |
||
94 | } |
||
95 | |||
96 | $table = $childRecord['tablenames']; |
||
97 | $uid = $parentUid; |
||
98 | |||
99 | if ($this->isValidRecord($table, $uid)) { |
||
100 | $arguments = GeneralUtility::_GET(); |
||
101 | // The arguments array is different in case this is called by an AJAX request |
||
102 | // via an IRRE inside an IRRE... |
||
103 | if (!isset($arguments['edit'])) { |
||
104 | $url = \parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER')); |
||
105 | \parse_str($url['query'], $arguments); |
||
106 | } |
||
107 | $returnUrl = [ |
||
108 | 'edit' => $arguments['edit'], |
||
109 | 'returnUrl' => $arguments['returnUrl'], |
||
110 | ]; |
||
111 | |||
112 | $wizardArguments = [ |
||
113 | 'P' => [ |
||
114 | 'referenceUid' => $childRecord['uid'], |
||
115 | 'returnUrl' => BackendUtility::getModuleUrl('record_edit', $returnUrl), |
||
116 | ], |
||
117 | ]; |
||
118 | $wizardUri = BackendUtility::getModuleUrl('focuspoint', $wizardArguments); |
||
119 | } else { |
||
120 | $wizardUri = 'javascript:alert(\'Please save the base record first, because open this wizard will not save the changes in the current form!\');'; |
||
121 | } |
||
122 | /** @var WizardService $wizardService */ |
||
123 | $wizardService = GeneralUtility::makeInstance(WizardService::class); |
||
124 | $this->arrayUnshiftAssoc($controlItems, 'focuspoint', $wizardService->getWizardButton($wizardUri)); |
||
125 | } |
||
126 | |||
154 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.