We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 7 |
Paths | 17 |
Total Lines | 73 |
Code Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
37 | public function mainAction() |
||
38 | { |
||
39 | // Load current document. |
||
40 | $this->loadDocument($this->requestData); |
||
41 | if ($this->isDocMissingOrEmpty()) { |
||
42 | // Quit without doing anything if required variables are not set. |
||
43 | return; |
||
44 | } else { |
||
45 | if (!empty($this->requestData['logicalPage'])) { |
||
46 | $this->requestData['page'] = $this->document->getDoc()->getPhysicalPage($this->requestData['logicalPage']); |
||
47 | // The logical page parameter should not appear again |
||
48 | unset($this->requestData['logicalPage']); |
||
49 | } |
||
50 | // Set default values if not set. |
||
51 | // $this->requestData['page'] may be integer or string (physical structure @ID) |
||
52 | if ((int) $this->requestData['page'] > 0 || empty($this->requestData['page'])) { |
||
53 | $this->requestData['page'] = MathUtility::forceIntegerInRange((int) $this->requestData['page'], 1, $this->document->getDoc()->numPages, 1); |
||
54 | } else { |
||
55 | $this->requestData['page'] = array_search($this->requestData['page'], $this->document->getDoc()->physicalStructure); |
||
56 | } |
||
57 | $this->requestData['double'] = MathUtility::forceIntegerInRange($this->requestData['double'], 0, 1, 0); |
||
58 | } |
||
59 | |||
60 | $doc = $this->document->getDoc(); |
||
|
|||
61 | |||
62 | if (!empty($this->settings['targetPidMetadata'])) { |
||
63 | $metadataUrl = $this->uriBuilder |
||
64 | ->reset() |
||
65 | ->setTargetPageUid((int) $this->settings['targetPidMetadata']) |
||
66 | ->setCreateAbsoluteUri(true) |
||
67 | ->setArguments([ |
||
68 | 'tx_dlf' => [ |
||
69 | 'id' => $this->requestData['id'], |
||
70 | ], |
||
71 | ]) |
||
72 | ->build(); |
||
73 | } |
||
74 | |||
75 | $imageFileGroups = array_reverse(GeneralUtility::trimExplode(',', $this->extConf['fileGrpImages'])); |
||
76 | $fulltextFileGroups = GeneralUtility::trimExplode(',', $this->extConf['fileGrpFulltext']); |
||
77 | $config = [ |
||
78 | 'forceAbsoluteUrl' => !empty($this->settings['forceAbsoluteUrl']), |
||
79 | 'proxyFileGroups' => !empty($this->settings['useInternalProxy']) |
||
80 | ? array_merge($imageFileGroups, $fulltextFileGroups) |
||
81 | : [], |
||
82 | ]; |
||
83 | $tx_dlf_loaded = [ |
||
84 | 'state' => [ |
||
85 | 'documentId' => $this->requestData['id'], |
||
86 | 'page' => $this->requestData['page'], |
||
87 | 'simultaneousPages' => (int) $this->requestData['double'] + 1, |
||
88 | ], |
||
89 | 'urlTemplate' => $this->getUrlTemplate(), |
||
90 | 'metadataUrl' => $metadataUrl, |
||
91 | 'fileGroups' => [ |
||
92 | 'images' => $imageFileGroups, |
||
93 | 'fulltext' => $fulltextFileGroups, |
||
94 | 'download' => GeneralUtility::trimExplode(',', $this->extConf['fileGrpDownload']), |
||
95 | ], |
||
96 | 'document' => $this->document->getDoc()->toArray($this->uriBuilder, $config), |
||
97 | ]; |
||
98 | |||
99 | $docConfiguration = ' |
||
100 | window.addEventListener("DOMContentLoaded", function() { |
||
101 | const tx_dlf_loaded = ' . json_encode($tx_dlf_loaded) . '; |
||
102 | window.dispatchEvent(new CustomEvent("tx-dlf-documentLoaded", { |
||
103 | detail: { |
||
104 | docController: new dlfController(tx_dlf_loaded) |
||
105 | } |
||
106 | })); |
||
107 | });'; |
||
108 | |||
109 | $this->view->assign('docConfiguration', $docConfiguration); |
||
110 | } |
||
186 |