aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/AppFramework/Http/TemplateResponse.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/AppFramework/Http/TemplateResponse.php')
-rw-r--r--lib/public/AppFramework/Http/TemplateResponse.php62
1 files changed, 22 insertions, 40 deletions
diff --git a/lib/public/AppFramework/Http/TemplateResponse.php b/lib/public/AppFramework/Http/TemplateResponse.php
index 23843cd21d1..af37a1a2313 100644
--- a/lib/public/AppFramework/Http/TemplateResponse.php
+++ b/lib/public/AppFramework/Http/TemplateResponse.php
@@ -1,36 +1,27 @@
<?php
+
+declare(strict_types=1);
+
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Thomas Tanghus <thomas@tanghus.net>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
+
namespace OCP\AppFramework\Http;
+use OCP\AppFramework\Http;
+use OCP\Server;
+use OCP\Template\ITemplateManager;
+
/**
* Response for a normal template
* @since 6.0.0
+ *
+ * @template S of Http::STATUS_*
+ * @template H of array<string, mixed>
+ * @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class TemplateResponse extends Response {
/**
@@ -59,15 +50,6 @@ class TemplateResponse extends Response {
public const RENDER_AS_PUBLIC = 'public';
/**
- * @deprecated 20.0.0 use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent
- */
- public const EVENT_LOAD_ADDITIONAL_SCRIPTS = self::class . '::loadAdditionalScripts';
- /**
- * @deprecated 20.0.0 use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent
- */
- public const EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN = self::class . '::loadAdditionalScriptsLoggedIn';
-
- /**
* name of the template
* @var string
*/
@@ -96,13 +78,14 @@ class TemplateResponse extends Response {
* @param string $appName the name of the app to load the template from
* @param string $templateName the name of the template
* @param array $params an array of parameters which should be passed to the
- * template
+ * template
* @param string $renderAs how the page should be rendered, defaults to user
+ * @param S $status
+ * @param H $headers
* @since 6.0.0 - parameters $params and $renderAs were added in 7.0.0
*/
- public function __construct($appName, $templateName, array $params = [],
- $renderAs = self::RENDER_AS_USER) {
- parent::__construct();
+ public function __construct(string $appName, string $templateName, array $params = [], string $renderAs = self::RENDER_AS_USER, int $status = Http::STATUS_OK, array $headers = []) {
+ parent::__construct($status, $headers);
$this->templateName = $templateName;
$this->appName = $appName;
@@ -203,8 +186,7 @@ class TemplateResponse extends Response {
$renderAs = $this->renderAs;
}
- \OCP\Util::addHeader('meta', ['name' => 'robots', 'content' => 'noindex, nofollow']);
- $template = new \OCP\Template($this->appName, $this->templateName, $renderAs);
+ $template = Server::get(ITemplateManager::class)->getTemplate($this->appName, $this->templateName, $renderAs);
foreach ($this->params as $key => $value) {
$template->assign($key, $value);