Conditions | 10 |
Paths | 8 |
Total Lines | 69 |
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 |
||
58 | public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$reference) |
||
59 | { |
||
60 | if ($table === 'tt_content' && $status == 'update' && isset($fieldArray['pi_flexform'])) { |
||
61 | $checkFields = [ |
||
62 | 'notification' => [ |
||
63 | 'settings.notification.senderEmail', |
||
64 | 'settings.notification.senderName', |
||
65 | 'settings.notification.adminEmail', |
||
66 | 'settings.notification.replyToEmail', |
||
67 | 'settings.notification.registrationNew.userSubject', |
||
68 | 'settings.notification.registrationWaitlistNew.userSubject', |
||
69 | 'settings.notification.registrationNew.adminSubject', |
||
70 | 'settings.notification.registrationWaitlistNew.adminSubject', |
||
71 | 'settings.notification.registrationConfirmed.userSubject', |
||
72 | 'settings.notification.registrationWaitlistConfirmed.userSubject', |
||
73 | 'settings.notification.registrationConfirmed.adminSubject', |
||
74 | 'settings.notification.registrationWaitlistConfirmed.adminSubject', |
||
75 | 'settings.notification.registrationCancelled.userSubject', |
||
76 | 'settings.notification.registrationCancelled.adminSubject', |
||
77 | ], |
||
78 | 'sDEF' => [ |
||
79 | 'settings.displayMode', |
||
80 | 'settings.orderField', |
||
81 | 'settings.orderDirection', |
||
82 | 'settings.topEventRestriction', |
||
83 | 'settings.queryLimit', |
||
84 | 'settings.category', |
||
85 | 'settings.storagePage', |
||
86 | 'settings.registration.requiredFields', |
||
87 | 'settings.userRegistration.displayMode', |
||
88 | 'settings.userRegistration.orderField', |
||
89 | 'settings.userRegistration.orderDirection', |
||
90 | 'settings.userRegistration.storagePage', |
||
91 | 'settings.userRegistration.recursive' |
||
92 | ], |
||
93 | 'additional' => [ |
||
94 | 'settings.detailPid', |
||
95 | 'settings.listPid', |
||
96 | 'settings.registrationPid', |
||
97 | 'settings.paymentPid', |
||
98 | 'settings.restrictForeignRecordsToStoragePage', |
||
99 | 'settings.disableOverrideDemand' |
||
100 | ], |
||
101 | 'template' => [ |
||
102 | 'settings.templateLayout' |
||
103 | ] |
||
104 | ]; |
||
105 | |||
106 | $flexformData = GeneralUtility::xml2array($fieldArray['pi_flexform']); |
||
107 | foreach ($checkFields as $sheet => $fields) { |
||
108 | foreach ($fields as $field) { |
||
109 | if (isset($flexformData['data'][$sheet]['lDEF'][$field]['vDEF']) && |
||
110 | $flexformData['data'][$sheet]['lDEF'][$field]['vDEF'] === '' |
||
111 | ) { |
||
112 | unset($flexformData['data'][$sheet]['lDEF'][$field]); |
||
113 | } |
||
114 | } |
||
115 | |||
116 | // If remaining sheet does not contain fields, then remove the sheet |
||
117 | if (isset($flexformData['data'][$sheet]['lDEF']) && $flexformData['data'][$sheet]['lDEF'] === []) { |
||
118 | unset($flexformData['data'][$sheet]); |
||
119 | } |
||
120 | } |
||
121 | |||
122 | /** @var \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools $flexFormTools */ |
||
123 | $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class); |
||
124 | $fieldArray['pi_flexform'] = $flexFormTools->flexArray2Xml($flexformData, true); |
||
125 | } |
||
126 | } |
||
127 | |||
166 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.