aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2025-03-03 11:38:39 +0100
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>2025-03-06 15:49:25 +0100
commitf033ef7c18f87284c15a55321ec727b41836132c (patch)
tree7fc19609d8b52736440cfc83c8a03fbf09b4ddda /lib
parent7d64c63acf9cf5ef18dd36ccb1883a3540bf86c7 (diff)
downloadnextcloud-server-f033ef7c18f87284c15a55321ec727b41836132c.tar.gz
nextcloud-server-f033ef7c18f87284c15a55321ec727b41836132c.zip
fix: Migrate all uses of OCP\Template to OCP\Template\ITemplateManager
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php2
-rw-r--r--lib/private/Template/TemplateManager.php6
-rw-r--r--lib/public/AppFramework/Http/TemplateResponse.php8
-rw-r--r--lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php7
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php8
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IProvider.php8
6 files changed, 21 insertions, 18 deletions
diff --git a/lib/base.php b/lib/base.php
index 618b392e337..65cb6328754 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -824,7 +824,7 @@ class OC {
]
);
- $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest');
+ $tmpl = Server::get(ITemplateManager::class)->getTemplate('core', 'untrustedDomain', 'guest');
$tmpl->assign('docUrl', Server::get(IURLGenerator::class)->linkToDocs('admin-trusted-domains'));
$tmpl->printPage();
diff --git a/lib/private/Template/TemplateManager.php b/lib/private/Template/TemplateManager.php
index f4bd1d1646b..e57203ba2da 100644
--- a/lib/private/Template/TemplateManager.php
+++ b/lib/private/Template/TemplateManager.php
@@ -40,7 +40,7 @@ class TemplateManager implements ITemplateManager {
* @param array $parameters Parameters for the template
*/
public function printGuestPage(string $application, string $name, array $parameters = []): void {
- $content = new Template($application, $name, $name === 'error' ? $name : 'guest');
+ $content = $this->getTemplate($application, $name, $name === 'error' ? $name : 'guest');
foreach ($parameters as $key => $value) {
$content->assign($key, $value);
}
@@ -85,7 +85,7 @@ class TemplateManager implements ITemplateManager {
try {
// Try rendering unthemed html error page
- $content = new Template('', 'error', 'error', false);
+ $content = $this->getTemplate('', 'error', 'error', false);
$content->assign('errors', $errors);
$content->printPage();
} catch (\Exception $e2) {
@@ -113,7 +113,7 @@ class TemplateManager implements ITemplateManager {
$debug = (bool)Server::get(\OC\SystemConfig::class)->getValue('debug', false);
$serverLogsDocumentation = Server::get(\OC\SystemConfig::class)->getValue('documentation_url.server_logs', '');
$request = Server::get(IRequest::class);
- $content = new Template('', 'exception', 'error', false);
+ $content = $this->getTemplate('', 'exception', 'error', false);
$content->assign('errorClass', get_class($exception));
$content->assign('errorMsg', $exception->getMessage());
$content->assign('errorCode', $exception->getCode());
diff --git a/lib/public/AppFramework/Http/TemplateResponse.php b/lib/public/AppFramework/Http/TemplateResponse.php
index 55b9f2b06af..af37a1a2313 100644
--- a/lib/public/AppFramework/Http/TemplateResponse.php
+++ b/lib/public/AppFramework/Http/TemplateResponse.php
@@ -1,13 +1,19 @@
<?php
+declare(strict_types=1);
+
+
/**
* 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
@@ -180,7 +186,7 @@ class TemplateResponse extends Response {
$renderAs = $this->renderAs;
}
- $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);
diff --git a/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php b/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php
index 84b0a9066f2..32ede4f385c 100644
--- a/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php
+++ b/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php
@@ -8,16 +8,15 @@ declare(strict_types=1);
*/
namespace OCP\Authentication\TwoFactorAuth;
-use OCP\Template;
+use OCP\Template\ITemplate;
/**
* @since 17.0.0
*/
interface ILoginSetupProvider {
/**
- * @return Template
- *
* @since 17.0.0
+ * @since 32.0.0 Broader return type ITemplate instead of \OCP\Template
*/
- public function getBody(): Template;
+ public function getBody(): ITemplate;
}
diff --git a/lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php b/lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php
index 610f299c526..3cf7946272e 100644
--- a/lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php
+++ b/lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php
@@ -6,9 +6,10 @@ declare(strict_types=1);
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+
namespace OCP\Authentication\TwoFactorAuth;
-use OCP\Template;
+use OCP\Template\ITemplate;
/**
* Interface IPersonalProviderSettings
@@ -17,9 +18,8 @@ use OCP\Template;
*/
interface IPersonalProviderSettings {
/**
- * @return Template
- *
* @since 15.0.0
+ * @since 32.0.0 Broader return type ITemplate instead of \OCP\Template
*/
- public function getBody(): Template;
+ public function getBody(): ITemplate;
}
diff --git a/lib/public/Authentication/TwoFactorAuth/IProvider.php b/lib/public/Authentication/TwoFactorAuth/IProvider.php
index f1dd24ff0a2..27c4121f4ac 100644
--- a/lib/public/Authentication/TwoFactorAuth/IProvider.php
+++ b/lib/public/Authentication/TwoFactorAuth/IProvider.php
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace OCP\Authentication\TwoFactorAuth;
use OCP\IUser;
-use OCP\Template;
+use OCP\Template\ITemplate;
/**
* @since 9.1.0
@@ -50,11 +50,9 @@ interface IProvider {
* Get the template for rending the 2FA provider view
*
* @since 9.1.0
- *
- * @param IUser $user
- * @return Template
+ * @since 32.0.0 Broader return type ITemplate instead of \OCP\Template.
*/
- public function getTemplate(IUser $user): Template;
+ public function getTemplate(IUser $user): ITemplate;
/**
* Verify the given challenge