Skip to content

Commit dbf99ec

Browse files
authored
Merge pull request #6200 from WoltLab/6.2-template-engine-render
Replace `TemplateEngine::fetch()` with `TemplateEngine::render()`
2 parents c45eee1 + a3239af commit dbf99ec

File tree

146 files changed

+386
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+386
-516
lines changed

wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ protected function stepPrepare(): ResponseInterface
109109
$nextNode
110110
);
111111

112-
WCF::getTPL()->assign([
113-
'installationType' => $this->queue->action,
114-
'packageName' => $this->installation->queue->packageName,
115-
]);
116-
117112
return new JsonResponse([
118-
'template' => WCF::getTPL()->fetch('packageInstallationStepPrepare'),
113+
'template' => WCF::getTPL()->render('wcf', 'packageInstallationStepPrepare', [
114+
'installationType' => $this->queue->action,
115+
'packageName' => $this->installation->queue->packageName,
116+
]),
119117
'step' => 'install',
120118
'node' => $nextNode,
121119
'currentAction' => $this->getCurrentAction($queueID),

wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ protected function stepPrepare(): ResponseInterface
130130
$nextNode
131131
);
132132

133-
WCF::getTPL()->assign([
134-
'queue' => $queue,
135-
]);
136-
137133
return new JsonResponse([
138-
'template' => WCF::getTPL()->fetch('packageUninstallationStepPrepare'),
134+
'template' => WCF::getTPL()->render('wcf', 'packageUninstallationStepPrepare', [
135+
'queue' => $queue,
136+
]),
139137
'step' => 'uninstall',
140138
'node' => $nextNode,
141139
'currentAction' => $this->getCurrentAction($queueID),

wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected function sendResponse($progress = 0, ?array $parameters = null, $proce
132132

133133
// include template on startup
134134
if ($this->loopCount == -1) {
135-
$returnValues['template'] = WCF::getTPL()->fetch('shared_worker');
135+
$returnValues['template'] = WCF::getTPL()->render('wcf', 'shared_worker', []);
136136
}
137137

138138
// send JSON-encoded response

wcfsetup/install/files/lib/action/UserPopoverAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
3838
}
3939

4040
return new HtmlResponse(
41-
WCF::getTPL()->fetch('userCard', 'wcf', ['user' => $user]),
41+
WCF::getTPL()->render('wcf', 'userCard', ['user' => $user]),
4242
);
4343
}
4444
}

wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProvider.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected function getOutputForUserConsent($url, $html)
168168
return $html;
169169
}
170170

171-
return WCF::getTPL()->fetch('messageUserConsent', 'wcf', [
171+
return WCF::getTPL()->render('wcf', 'messageUserConsent', [
172172
'host' => Url::parse($url)['host'],
173173
'payload' => \base64_encode($html),
174174
'url' => $url,

wcfsetup/install/files/lib/data/box/Box.class.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,9 @@ public function render()
314314
return '';
315315
}
316316

317-
WCF::getTPL()->assign([
317+
return WCF::getTPL()->render('wcf', '__box', [
318318
'box' => $this,
319319
]);
320-
321-
return WCF::getTPL()->fetch('__box');
322320
}
323321

324322
/**

wcfsetup/install/files/lib/data/box/content/BoxContent.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function getParsedTemplate($templateName)
140140

141141
WCF::getTPL()->registerPrefilter(['simpleEmbeddedObject']);
142142

143-
$returnValue = WCF::getTPL()->fetch($templateName);
143+
$returnValue = WCF::getTPL()->render('wcf', $templateName, []);
144144

145145
WCF::getTPL()->removePrefilter('simpleEmbeddedObject');
146146

wcfsetup/install/files/lib/data/comment/CommentAction.class.php

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,12 @@ public function loadComments()
163163
$commentList->getObjects()
164164
);
165165

166-
WCF::getTPL()->assign([
167-
'commentList' => $commentList,
168-
'likeData' => MODULE_LIKE ? $commentList->getLikeData() : [],
169-
]);
170-
171166
return [
172167
'lastCommentTime' => $commentList->getMinCommentTime(),
173-
'template' => WCF::getTPL()->fetch('commentList'),
168+
'template' => WCF::getTPL()->render('wcf', 'commentList', [
169+
'commentList' => $commentList,
170+
'likeData' => MODULE_LIKE ? $commentList->getLikeData() : [],
171+
]),
174172
];
175173
}
176174

@@ -829,15 +827,14 @@ public function beginEdit()
829827
{
830828
$upcastProcessor = new HtmlUpcastProcessor();
831829
$upcastProcessor->process($this->comment->message, 'com.woltlab.wcf.comment');
832-
WCF::getTPL()->assign([
833-
'comment' => $this->comment,
834-
'text' => $upcastProcessor->getHtml(),
835-
'wysiwygSelector' => 'commentEditor' . $this->comment->commentID,
836-
]);
837830

838831
return [
839832
'actionName' => 'beginEdit',
840-
'template' => WCF::getTPL()->fetch('commentEditor', 'wcf'),
833+
'template' => WCF::getTPL()->render('wcf', 'commentEditor', [
834+
'comment' => $this->comment,
835+
'text' => $upcastProcessor->getHtml(),
836+
'wysiwygSelector' => 'commentEditor' . $this->comment->commentID,
837+
]),
841838
];
842839
}
843840

@@ -999,7 +996,7 @@ private function getGuestDialog(): ?string
999996
}
1000997
}
1001998

1002-
return WCF::getTPL()->fetch('commentAddGuestDialog', 'wcf', [
999+
return WCF::getTPL()->render('wcf', 'commentAddGuestDialog', [
10031000
'ajaxCaptcha' => true,
10041001
'captchaID' => 'commentAdd',
10051002
'captchaObjectType' => $captchaObjectType,
@@ -1046,14 +1043,15 @@ protected function renderComment(Comment $comment, ?CommentResponse $response =
10461043
}
10471044
}
10481045

1046+
$tplVariables = [];
10491047
// This functions renders a single comment without rendering its responses.
10501048
// We need to prevent the setting of the data attribute for the last response time
10511049
// so that the loading of the responses by the user works correctly.
10521050
if ($comment->getDecoratedObject()->responses) {
1053-
WCF::getTPL()->assign('ignoreLastResponseTime', true);
1051+
$tplVariables['ignoreLastResponseTime'] = true;
10541052
}
10551053

1056-
WCF::getTPL()->assign([
1054+
$tplVariables = \array_merge($tplVariables, [
10571055
'commentCanAdd' => $this->commentProcessor->canAdd(
10581056
$comment->getDecoratedObject()->objectID
10591057
),
@@ -1087,10 +1085,10 @@ protected function renderComment(Comment $comment, ?CommentResponse $response =
10871085
$likeData['response'] = ReactionHandler::getInstance()->getLikeObjects($responseObjectType);
10881086
}
10891087

1090-
WCF::getTPL()->assign('likeData', $likeData);
1088+
$tplVariables['likeData'] = $likeData;
10911089
}
10921090

1093-
$template = WCF::getTPL()->fetch('commentList');
1091+
$template = WCF::getTPL()->render('wcf', 'commentList', $tplVariables);
10941092
if ($response === null) {
10951093
return $template;
10961094
}
@@ -1122,16 +1120,14 @@ protected function renderResponse(CommentResponse $response)
11221120
}
11231121

11241122
// render response
1125-
WCF::getTPL()->assign([
1123+
return WCF::getTPL()->render('wcf', 'commentResponseList', [
11261124
'responseList' => [$response],
11271125
'commentCanModerate' => $this->commentProcessor->canModerate(
11281126
$response->getComment()->objectTypeID,
11291127
$response->getComment()->objectID
11301128
),
11311129
'commentManager' => $this->commentProcessor,
11321130
]);
1133-
1134-
return WCF::getTPL()->fetch('commentResponseList');
11351131
}
11361132

11371133
/**

wcfsetup/install/files/lib/data/comment/response/CommentResponseAction.class.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,16 @@ public function loadResponses()
151151
$responseList->getObjects()
152152
);
153153

154-
WCF::getTPL()->assign([
155-
'commentCanModerate' => $commentCanModerate,
156-
'likeData' => MODULE_LIKE ? $responseList->getLikeData() : [],
157-
'responseList' => $responseList,
158-
'commentManager' => $this->commentManager,
159-
]);
160-
161154
return [
162155
'commentID' => $this->comment->commentID,
163156
'lastResponseTime' => $lastResponseTime,
164157
'lastResponseID' => $lastResponseID,
165-
'template' => WCF::getTPL()->fetch('commentResponseList'),
158+
'template' => WCF::getTPL()->render('wcf', 'commentResponseList', [
159+
'commentCanModerate' => $commentCanModerate,
160+
'likeData' => MODULE_LIKE ? $responseList->getLikeData() : [],
161+
'responseList' => $responseList,
162+
'commentManager' => $this->commentManager,
163+
]),
166164
];
167165
}
168166

@@ -191,15 +189,14 @@ public function beginEdit()
191189
{
192190
$upcastProcessor = new HtmlUpcastProcessor();
193191
$upcastProcessor->process($this->response->message, 'com.woltlab.wcf.comment.response');
194-
WCF::getTPL()->assign([
195-
'response' => $this->response,
196-
'text' => $upcastProcessor->getHtml(),
197-
'wysiwygSelector' => 'commentResponseEditor' . $this->response->responseID,
198-
]);
199192

200193
return [
201194
'actionName' => 'beginEdit',
202-
'template' => WCF::getTPL()->fetch('commentResponseEditor', 'wcf'),
195+
'template' => WCF::getTPL()->render('wcf', 'commentResponseEditor', [
196+
'response' => $this->response,
197+
'text' => $upcastProcessor->getHtml(),
198+
'wysiwygSelector' => 'commentResponseEditor' . $this->response->responseID,
199+
]),
203200
];
204201
}
205202

wcfsetup/install/files/lib/data/devtools/missing/language/item/DevtoolsMissingLanguageItem.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getStackTrace()
4949
{
5050
$stackTrace = JSON::decode($this->stackTrace);
5151

52-
return WCF::getTPL()->fetch('__devtoolsMissingLanguageItemStackTrace', 'wcf', [
52+
return WCF::getTPL()->render('wcf', '__devtoolsMissingLanguageItemStackTrace', [
5353
'stackTrace' => $stackTrace,
5454
]);
5555
}

0 commit comments

Comments
 (0)