Conditions | 12 |
Paths | 9 |
Total Lines | 54 |
Code Lines | 31 |
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 |
||
40 | public function generateItems(ServerRequestInterface $request): void |
||
41 | { |
||
42 | $site = $request->getAttribute('site'); |
||
43 | $rootPageId = $site->getRootPageId(); |
||
44 | |||
45 | $additionalWhere = $this->config['additionalWhere'] ?? ''; |
||
46 | if (!empty($this->config['excludedDoktypes'])) { |
||
47 | $excludedDoktypes = GeneralUtility::trimExplode(',', $this->config['excludedDoktypes']); |
||
48 | if (!empty($excludedDoktypes)) { |
||
49 | $additionalWhere .= ' AND doktype NOT IN (' . implode(',', $excludedDoktypes) . ')'; |
||
50 | } |
||
51 | } |
||
52 | |||
53 | $rootPage = $this->getTypoScriptFrontendController()->page; |
||
54 | $pages = [ |
||
55 | [ |
||
56 | 'uid' => $rootPage['uid'], |
||
57 | 'tstamp' => $rootPage['tstamp'], |
||
58 | 'l18n_cfg' => $rootPage['l18n_cfg'], |
||
59 | 'SYS_LASTCHANGED' => $rootPage['SYS_LASTCHANGED'] |
||
60 | ] |
||
61 | ]; |
||
62 | |||
63 | $pages = $this->getSubPages($rootPageId, $pages, ltrim($additionalWhere)); |
||
64 | |||
65 | $languageId = $this->getCurrentLanguageAspect()->getId(); |
||
66 | foreach ($pages as $page) { |
||
67 | /** |
||
68 | * @todo Checking if the page has to be shown/hidden should normally be handled by the |
||
69 | * PageRepository but to prevent major breaking changes this is checked here for now |
||
70 | */ |
||
71 | if ( |
||
72 | !( |
||
73 | GeneralUtility::hideIfDefaultLanguage($page['l18n_cfg']) |
||
74 | && (!$languageId || ($languageId && !$page['_PAGES_OVERLAY'])) |
||
75 | ) |
||
76 | && |
||
77 | !( |
||
78 | $languageId |
||
79 | && GeneralUtility::hideIfNotTranslated($page['l18n_cfg']) |
||
80 | && !$page['_PAGES_OVERLAY'] |
||
81 | ) |
||
82 | ) { |
||
83 | $typoLinkConfig = [ |
||
84 | 'parameter' => $page['uid'], |
||
85 | 'forceAbsoluteUrl' => 1, |
||
86 | ]; |
||
87 | |||
88 | $loc = $this->cObj->typoLink_URL($typoLinkConfig); |
||
89 | $lastMod = $page['SYS_LASTCHANGED'] ?: $page['tstamp']; |
||
90 | |||
91 | $this->items[] = [ |
||
92 | 'loc' => $loc, |
||
93 | 'lastMod' => (int)$lastMod |
||
94 | ]; |
||
142 |