We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 13 |
| Paths | 220 |
| Total Lines | 145 |
| Code Lines | 99 |
| 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 |
||
| 203 | public function main(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response) { |
||
| 204 | $this->response = $response; |
||
| 205 | // Is the user allowed to access this page? |
||
| 206 | $access = is_array($this->pageInfo) && $GLOBALS['BE_USER']->isAdmin(); |
||
| 207 | if ($this->id && $access) { |
||
| 208 | // Check if page is sysfolder. |
||
| 209 | if ($this->pageInfo['doktype'] != 254) { |
||
| 210 | Helper::addMessage( |
||
| 211 | Helper::getMessage('flash.wrongPageTypeMsg'), |
||
| 212 | Helper::getMessage('flash.wrongPageType', TRUE), |
||
| 213 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 214 | ); |
||
| 215 | $this->markerArray['CONTENT'] .= Helper::renderFlashMessages(); |
||
| 216 | $this->printContent(); |
||
| 217 | return; |
||
| 218 | } |
||
| 219 | // Should we do something? |
||
| 220 | if (!empty($this->CMD)) { |
||
| 221 | // Sanitize input... |
||
| 222 | $_method = 'cmd'.ucfirst($this->CMD); |
||
| 223 | // ...and unset to prevent infinite looping. |
||
| 224 | unset ($this->CMD); |
||
| 225 | if (method_exists($this, $_method)) { |
||
| 226 | $this->$_method(); |
||
| 227 | } |
||
| 228 | } |
||
| 229 | // Check for existing structure configuration. |
||
| 230 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 231 | 'uid', |
||
| 232 | 'tx_dlf_structures', |
||
| 233 | 'pid='.intval($this->id).$GLOBALS['LANG']->whereClause('tx_dlf_structures') |
||
| 234 | ); |
||
| 235 | if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
||
| 236 | // Fine. |
||
| 237 | Helper::addMessage( |
||
| 238 | Helper::getMessage('flash.structureOkayMsg'), |
||
| 239 | Helper::getMessage('flash.structureOkay', TRUE), |
||
| 240 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK |
||
| 241 | ); |
||
| 242 | } else { |
||
| 243 | // Configuration missing. |
||
| 244 | $_url = \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(['id' => $this->id, 'CMD' => 'addStructure'])); |
||
| 245 | Helper::addMessage( |
||
| 246 | sprintf(Helper::getMessage('flash.structureNotOkayMsg'), $_url), |
||
| 247 | Helper::getMessage('flash.structureNotOkay', TRUE), |
||
| 248 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 249 | ); |
||
| 250 | } |
||
| 251 | // Check for existing metadata configuration. |
||
| 252 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 253 | 'uid', |
||
| 254 | 'tx_dlf_metadata', |
||
| 255 | 'pid='.intval($this->id) |
||
| 256 | .Helper::whereClause('tx_dlf_metadata') |
||
| 257 | ); |
||
| 258 | if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
||
| 259 | // Fine. |
||
| 260 | Helper::addMessage( |
||
| 261 | Helper::getMessage('flash.metadataOkayMsg'), |
||
| 262 | Helper::getMessage('flash.metadataOkay', TRUE), |
||
| 263 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK |
||
| 264 | ); |
||
| 265 | } else { |
||
| 266 | // Configuration missing. |
||
| 267 | $_url = \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(['id' => $this->id, 'CMD' => 'addMetadata'])); |
||
| 268 | Helper::addMessage( |
||
| 269 | sprintf(Helper::getMessage('flash.metadataNotOkayMsg'), $_url), |
||
| 270 | Helper::getMessage('flash.metadataNotOkay', TRUE), |
||
| 271 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 272 | ); |
||
| 273 | } |
||
| 274 | // Check the access conditions for the command line indexer's user. |
||
| 275 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 276 | 'uid,db_mountpoints', |
||
| 277 | 'be_groups', |
||
| 278 | 'title='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_cli_dlf', 'be_groups') |
||
| 279 | .' AND '.$GLOBALS['TCA']['be_groups']['ctrl']['enablecolumns']['disabled'].'=0' |
||
| 280 | .\TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('be_groups') |
||
| 281 | ); |
||
| 282 | if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
||
| 283 | $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
||
| 284 | if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($resArray['db_mountpoints'], $this->id)) { |
||
| 285 | // Fine. |
||
| 286 | Helper::addMessage( |
||
| 287 | Helper::getMessage('flash.usergroupOkayMsg'), |
||
| 288 | Helper::getMessage('flash.usergroupOkay', TRUE), |
||
| 289 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK |
||
| 290 | ); |
||
| 291 | } else { |
||
| 292 | // Configuration missing. |
||
| 293 | $_url = \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(['id' => $this->id, 'CMD' => 'addAccessRights'])); |
||
| 294 | Helper::addMessage( |
||
| 295 | sprintf(Helper::getMessage('flash.usergroupNotOkayMsg'), $_url), |
||
| 296 | Helper::getMessage('flash.usergroupNotOkay', TRUE), |
||
| 297 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 298 | ); |
||
| 299 | } |
||
| 300 | } else { |
||
| 301 | // Usergoup missing. |
||
| 302 | Helper::addMessage( |
||
| 303 | Helper::getMessage('flash.usergroupMissingMsg'), |
||
| 304 | Helper::getMessage('flash.usergroupMissing', TRUE), |
||
| 305 | \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
||
| 306 | ); |
||
| 307 | } |
||
| 308 | // Check for existing Solr core. |
||
| 309 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 310 | 'uid,pid', |
||
| 311 | 'tx_dlf_solrcores', |
||
| 312 | 'pid IN ('.intval($this->id).',0)' |
||
| 313 | .Helper::whereClause('tx_dlf_solrcores') |
||
| 314 | ); |
||
| 315 | if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
||
| 316 | $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
||
| 317 | if ($resArray['pid']) { |
||
| 318 | // Fine. |
||
| 319 | Helper::addMessage( |
||
| 320 | Helper::getMessage('flash.solrcoreOkayMsg'), |
||
| 321 | Helper::getMessage('flash.solrcoreOkay', TRUE), |
||
| 322 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK |
||
| 323 | ); |
||
| 324 | } else { |
||
| 325 | // Default core available, but this is deprecated. |
||
| 326 | $_url = \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(['id' => $this->id, 'CMD' => 'addSolrcore'])); |
||
| 327 | Helper::addMessage( |
||
| 328 | sprintf(Helper::getMessage('flash.solrcoreDeprecatedMsg'), $_url), |
||
| 329 | Helper::getMessage('flash.solrcoreDeprecatedOkay', TRUE), |
||
| 330 | \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE |
||
| 331 | ); |
||
| 332 | } |
||
| 333 | } else { |
||
| 334 | // Solr core missing. |
||
| 335 | $_url = \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(['id' => $this->id, 'CMD' => 'addSolrcore'])); |
||
| 336 | Helper::addMessage( |
||
| 337 | sprintf(Helper::getMessage('flash.solrcoreMissingMsg'), $_url), |
||
| 338 | Helper::getMessage('flash.solrcoreMissing', TRUE), |
||
| 339 | \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING |
||
| 340 | ); |
||
| 341 | } |
||
| 342 | $this->markerArray['CONTENT'] .= Helper::renderFlashMessages(); |
||
| 343 | } else { |
||
| 344 | // TODO: Ändern! |
||
| 345 | $this->markerArray['CONTENT'] .= 'You are not allowed to access this page or have not selected a page, yet.'; |
||
| 346 | } |
||
| 347 | $this->printContent(); |
||
| 348 | } |
||
| 350 |