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