Skip to content

Commit 6b33461

Browse files
[MAINTENANCE] Migrate kitodo#1640 to main branch (kitodo#1716)
1 parent f738b6f commit 6b33461

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Classes/Controller/AbstractController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function injectDocumentRepository(DocumentRepository $documentRepository)
9696

9797
/**
9898
* @access protected
99-
* @var int
99+
* @var int This holds the current page UID (only in frontend context)
100100
*/
101101
protected int $pageUid;
102102

@@ -121,8 +121,10 @@ protected function initialize(RequestInterface $request): void
121121
{
122122
/** @var Request $request */
123123
$this->requestData = $request->getQueryParams()['tx_dlf'] ?? [];
124-
$this->pageUid = (int) ($request->getQueryParams()['id'] ?? null);
125124
$this->requestData['page'] = $this->requestData['page'] ?? 1;
125+
if ($request->getAttribute('applicationType') === 1) {
126+
$this->pageUid = $request->getAttribute('routing')->getPageId();
127+
}
126128

127129
// Sanitize user input to prevent XSS attacks.
128130
$this->sanitizeRequestData();
@@ -135,14 +137,14 @@ protected function initialize(RequestInterface $request): void
135137
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
136138

137139
$this->viewData = [
138-
'pageUid' => $this->pageUid,
140+
'pageUid' => $this->pageUid ?? 0,
139141
'uniqueId' => uniqid(),
140142
'requestData' => $this->requestData
141143
];
142144

143145
// TODO: ViewHelper f:link.action / UriBuilder does not properly encode specified entities in URL parameter
144146
// For more details, please see the following TYPO3 issue https://forge.typo3.org/issues/107026
145-
if ( isset($this->requestData['id']) ) {
147+
if (isset($this->requestData['id'])) {
146148
$this->viewData['partlyEncodedId'] = str_replace("%2F", "%252F", $this->requestData['id']);
147149
}
148150

0 commit comments

Comments
 (0)