| Conditions | 8 |
| Paths | 32 |
| Total Lines | 79 |
| Code Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 73 | private function showCrawlerInformationAction(int $pageId): string |
||
| 74 | { |
||
| 75 | $this->view->setTemplate('ShowCrawlerInformation'); |
||
| 76 | if (empty($pageId)) { |
||
| 77 | $this->isErrorDetected = true; |
||
| 78 | MessageUtility::addErrorMessage($this->getLanguageService()->sL('LLL:EXT:crawler/Resources/Private/Language/locallang.xlf:labels.noPageSelected')); |
||
| 79 | } else { |
||
| 80 | $crawlerParameter = GeneralUtility::_GP('_crawl'); |
||
| 81 | $downloadParameter = GeneralUtility::_GP('_download'); |
||
| 82 | |||
| 83 | $duplicateTrack = []; |
||
|
|
|||
| 84 | $submitCrawlUrls = isset($crawlerParameter); |
||
| 85 | $downloadCrawlUrls = isset($downloadParameter); |
||
| 86 | $this->makeCrawlerProcessableChecks($this->extensionSettings); |
||
| 87 | |||
| 88 | $scheduledTime = $this->getScheduledTime((string) GeneralUtility::_GP('tstamp')); |
||
| 89 | |||
| 90 | $this->incomingConfigurationSelection = GeneralUtility::_GP('configurationSelection'); |
||
| 91 | $this->incomingConfigurationSelection = is_array($this->incomingConfigurationSelection) ? $this->incomingConfigurationSelection : []; |
||
| 92 | |||
| 93 | $this->crawlerController = GeneralUtility::makeInstance(CrawlerController::class); |
||
| 94 | $this->crawlerController->setAccessMode('gui'); |
||
| 95 | $this->crawlerController->setID = GeneralUtility::md5int(microtime()); |
||
| 96 | |||
| 97 | $code = ''; |
||
| 98 | $noConfigurationSelected = empty($this->incomingConfigurationSelection) |
||
| 99 | || (count($this->incomingConfigurationSelection) === 1 && empty($this->incomingConfigurationSelection[0])); |
||
| 100 | if ($noConfigurationSelected) { |
||
| 101 | MessageUtility::addWarningMessage($this->getLanguageService()->sL('LLL:EXT:crawler/Resources/Private/Language/locallang.xlf:labels.noConfigSelected')); |
||
| 102 | } else { |
||
| 103 | if ($submitCrawlUrls) { |
||
| 104 | $reason = new Reason(); |
||
| 105 | $reason->setReason(Reason::REASON_GUI_SUBMIT); |
||
| 106 | $reason->setDetailText('The user ' . $GLOBALS['BE_USER']->user['username'] . ' added pages to the crawler queue manually'); |
||
| 107 | |||
| 108 | $signalPayload = ['reason' => $reason]; |
||
| 109 | SignalSlotUtility::emitSignal( |
||
| 110 | self::class, |
||
| 111 | SignalSlotUtility::SIGNAL_INVOKE_QUEUE_CHANGE, |
||
| 112 | $signalPayload |
||
| 113 | ); |
||
| 114 | } |
||
| 115 | |||
| 116 | $code = $this->crawlerController->getPageTreeAndUrls( |
||
| 117 | $pageId, |
||
| 118 | $this->infoModuleController->MOD_SETTINGS['depth'], |
||
| 119 | $scheduledTime, |
||
| 120 | $this->reqMinute, |
||
| 121 | $submitCrawlUrls, |
||
| 122 | $downloadCrawlUrls, |
||
| 123 | // Do not filter any processing instructions |
||
| 124 | [], |
||
| 125 | $this->incomingConfigurationSelection |
||
| 126 | ); |
||
| 127 | } |
||
| 128 | |||
| 129 | $downloadUrls = $this->crawlerController->downloadUrls; |
||
| 130 | |||
| 131 | $duplicateTrack = $this->crawlerController->duplicateTrack; |
||
| 132 | |||
| 133 | $this->view->assign('noConfigurationSelected', $noConfigurationSelected); |
||
| 134 | $this->view->assign('submitCrawlUrls', $submitCrawlUrls); |
||
| 135 | $this->view->assign('amountOfUrls', count(array_keys($duplicateTrack))); |
||
| 136 | $this->view->assign('selectors', $this->generateConfigurationSelectors()); |
||
| 137 | $this->view->assign('code', $code); |
||
| 138 | $this->view->assign('displayActions', 0); |
||
| 139 | |||
| 140 | // Download Urls to crawl: |
||
| 141 | if ($downloadCrawlUrls) { |
||
| 142 | // Creating output header: |
||
| 143 | header('Content-Type: application/octet-stream'); |
||
| 144 | header('Content-Disposition: attachment; filename=CrawlerUrls.txt'); |
||
| 145 | |||
| 146 | // Printing the content of the CSV lines: |
||
| 147 | echo implode(chr(13) . chr(10), $downloadUrls); |
||
| 148 | exit; |
||
| 149 | } |
||
| 150 | } |
||
| 151 | return $this->view->render(); |
||
| 152 | } |
||
| 244 |