We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 30 |
| Paths | 175 |
| Total Lines | 114 |
| Code Lines | 70 |
| 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 |
||
| 78 | public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray) |
||
| 79 | { |
||
| 80 | if ($status == 'new') { |
||
| 81 | switch ($table) { |
||
| 82 | // Field post-processing for table "tx_dlf_documents". |
||
| 83 | case 'tx_dlf_documents': |
||
| 84 | // Set sorting field if empty. |
||
| 85 | if ( |
||
| 86 | empty($fieldArray['title_sorting']) |
||
| 87 | && !empty($fieldArray['title']) |
||
| 88 | ) { |
||
| 89 | $fieldArray['title_sorting'] = $fieldArray['title']; |
||
| 90 | } |
||
| 91 | break; |
||
| 92 | // Field post-processing for table "tx_dlf_metadata". |
||
| 93 | case 'tx_dlf_metadata': |
||
| 94 | // Store field in index if it should appear in lists. |
||
| 95 | if (!empty($fieldArray['is_listed'])) { |
||
| 96 | $fieldArray['index_stored'] = 1; |
||
| 97 | } |
||
| 98 | // Index field in index if it should be used for auto-completion. |
||
| 99 | if (!empty($fieldArray['index_autocomplete'])) { |
||
| 100 | $fieldArray['index_indexed'] = 1; |
||
| 101 | } |
||
| 102 | // Field post-processing for tables "tx_dlf_metadata", "tx_dlf_collections", "tx_dlf_libraries" and "tx_dlf_structures". |
||
| 103 | case 'tx_dlf_collections': |
||
| 104 | case 'tx_dlf_libraries': |
||
| 105 | case 'tx_dlf_structures': |
||
| 106 | // Set label as index name if empty. |
||
| 107 | if ( |
||
| 108 | empty($fieldArray['index_name']) |
||
| 109 | && !empty($fieldArray['label']) |
||
| 110 | ) { |
||
| 111 | $fieldArray['index_name'] = $fieldArray['label']; |
||
| 112 | } |
||
| 113 | // Set index name as label if empty. |
||
| 114 | if ( |
||
| 115 | empty($fieldArray['label']) |
||
| 116 | && !empty($fieldArray['index_name']) |
||
| 117 | ) { |
||
| 118 | $fieldArray['label'] = $fieldArray['index_name']; |
||
| 119 | } |
||
| 120 | // Ensure that index names don't get mixed up with sorting values. |
||
| 121 | if (substr($fieldArray['index_name'], -8) == '_sorting') { |
||
| 122 | $fieldArray['index_name'] .= '0'; |
||
| 123 | } |
||
| 124 | break; |
||
| 125 | // Field post-processing for table "tx_dlf_solrcores". |
||
| 126 | case 'tx_dlf_solrcores': |
||
| 127 | // Create new Solr core. |
||
| 128 | $fieldArray['index_name'] = Solr::createCore($fieldArray['index_name']); |
||
| 129 | if (empty($fieldArray['index_name'])) { |
||
| 130 | $this->logger->error('Could not create new Apache Solr core'); |
||
| 131 | } |
||
| 132 | break; |
||
| 133 | } |
||
| 134 | } elseif ($status == 'update') { |
||
| 135 | switch ($table) { |
||
| 136 | // Field post-processing for table "tx_dlf_metadata". |
||
| 137 | case 'tx_dlf_metadata': |
||
| 138 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 139 | ->getQueryBuilderForTable($table); |
||
| 140 | |||
| 141 | // Store field in index if it should appear in lists. |
||
| 142 | if (!empty($fieldArray['is_listed'])) { |
||
| 143 | $fieldArray['index_stored'] = 1; |
||
| 144 | } |
||
| 145 | if ( |
||
| 146 | isset($fieldArray['index_stored']) |
||
| 147 | && $fieldArray['index_stored'] == 0 |
||
| 148 | && !isset($fieldArray['is_listed']) |
||
| 149 | ) { |
||
| 150 | // Get current configuration. |
||
| 151 | $result = $queryBuilder |
||
| 152 | ->select($table . '.is_listed AS is_listed') |
||
| 153 | ->from($table) |
||
| 154 | ->where( |
||
| 155 | $queryBuilder->expr()->eq($table . '.uid', intval($id)), |
||
| 156 | Helper::whereExpression($table) |
||
| 157 | ) |
||
| 158 | ->setMaxResults(1) |
||
| 159 | ->execute(); |
||
| 160 | |||
| 161 | if ($resArray = $result->fetch()) { |
||
| 162 | // Reset storing to current. |
||
| 163 | $fieldArray['index_stored'] = $resArray['is_listed']; |
||
| 164 | } |
||
| 165 | } |
||
| 166 | // Index field in index if it should be used for auto-completion. |
||
| 167 | if (!empty($fieldArray['index_autocomplete'])) { |
||
| 168 | $fieldArray['index_indexed'] = 1; |
||
| 169 | } |
||
| 170 | if ( |
||
| 171 | isset($fieldArray['index_indexed']) |
||
| 172 | && $fieldArray['index_indexed'] == 0 |
||
| 173 | && !isset($fieldArray['index_autocomplete']) |
||
| 174 | ) { |
||
| 175 | // Get current configuration. |
||
| 176 | $result = $queryBuilder |
||
| 177 | ->select($table . '.index_autocomplete AS index_autocomplete') |
||
| 178 | ->from($table) |
||
| 179 | ->where( |
||
| 180 | $queryBuilder->expr()->eq($table . '.uid', intval($id)), |
||
| 181 | Helper::whereExpression($table) |
||
| 182 | ) |
||
| 183 | ->setMaxResults(1) |
||
| 184 | ->execute(); |
||
| 185 | |||
| 186 | if ($resArray = $result->fetch()) { |
||
| 187 | // Reset indexing to current. |
||
| 188 | $fieldArray['index_indexed'] = $resArray['index_autocomplete']; |
||
| 189 | } |
||
| 190 | } |
||
| 191 | break; |
||
| 192 | } |
||
| 413 |