diff --git a/php-toolkit/Traits/Constants.php b/php-toolkit/Traits/Constants.php index 5cddb66..f10021a 100644 --- a/php-toolkit/Traits/Constants.php +++ b/php-toolkit/Traits/Constants.php @@ -3,7 +3,7 @@ * A collection of reusable traits classes for Nextcloud apps. * * @author Claus-Justus Heine - * @copyright 2022 Claus-Justus Heine + * @copyright 2022, 2024 Claus-Justus Heine * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify @@ -39,4 +39,12 @@ class Constants public const HASH = 'hash'; public const WEB_ASSET_META = self::JS . self::PATH_SEPARATOR . 'asset-meta.json'; public const INFO_FILE = 'appinfo' . self::PATH_SEPARATOR . 'info.xml'; + + // The following will be moved to the ResponseTrait as soon as >= PHP 8.2 is feasible + public const RENDER_AS_GUEST = TemplateResponse::RENDER_AS_GUEST; + public const RENDER_AS_BLANK = 'blank'; + public const RENDER_AS_BASE = TemplateResponse::RENDER_AS_BASE; + public const RENDER_AS_USER = TemplateResponse::RENDER_AS_USER; + public const RENDER_AS_ERROR = TemplateResponse::RENDER_AS_ERROR; + public const RENDER_AS_PUBLIC = TemplateResponse::RENDER_AS_PUBLIC; } diff --git a/php-toolkit/Traits/ResponseTrait.php b/php-toolkit/Traits/ResponseTrait.php index 7b64db5..14f3751 100644 --- a/php-toolkit/Traits/ResponseTrait.php +++ b/php-toolkit/Traits/ResponseTrait.php @@ -42,14 +42,16 @@ */ trait ResponseTrait { - protected const RENDER_AS_GUEST = TemplateResponse::RENDER_AS_GUEST; - protected const RENDER_AS_BLANK = 'blank'; - protected const RENDER_AS_BASE = TemplateResponse::RENDER_AS_BASE; - protected const RENDER_AS_USER = TemplateResponse::RENDER_AS_USER; - protected const RENDER_AS_ERROR = TemplateResponse::RENDER_AS_ERROR; - protected const RENDER_AS_PUBLIC = TemplateResponse::RENDER_AS_PUBLIC; + // In order to restore PHP 8.1 compatibility do not use constants in traits ... + // + // protected const RENDER_AS_GUEST = TemplateResponse::RENDER_AS_GUEST; + // protected const RENDER_AS_BLANK = 'blank'; + // protected const RENDER_AS_BASE = TemplateResponse::RENDER_AS_BASE; + // protected const RENDER_AS_USER = TemplateResponse::RENDER_AS_USER; + // protected const RENDER_AS_ERROR = TemplateResponse::RENDER_AS_ERROR; + // protected const RENDER_AS_PUBLIC = TemplateResponse::RENDER_AS_PUBLIC; - protected const APPNAME_PREFIX = 'app-'; + // protected const APPNAME_PREFIX = 'app-'; /** @var IL10N */ protected IL10N $l; @@ -87,7 +89,8 @@ protected function templateResponse( array_merge( [ 'appName' => $appName, - 'appNameTag' => self::APPNAME_PREFIX . $appName, + // 'appNameTag' => self::APPNAME_PREFIX . $appName, + 'appNameTag' => 'app-' . $appName, 'l10n' => $l10n, // do not conflict with core template $l parameter ], $params,