From bb0350886d71c968f6d6779756feb6c59e18034b Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Fri, 30 Aug 2024 16:05:18 +0200 Subject: [PATCH] [TASK] Deprecate TYPO3-specific code in TemplatePaths Ever since Fluid has been extracted from TYPO3, there has been some TYPO3-specific code in TemplatePaths. This patch removes some of these code paths. Simultaneously, TemplatePaths in TYPO3 13 has been adjusted accordingly. Soft-deprecations will be backported to Fluid v2 to let users know in advance that these methods or constants will no longer be available in the future. --- src/View/TemplatePaths.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/View/TemplatePaths.php b/src/View/TemplatePaths.php index ad01953a2..7e72b174c 100644 --- a/src/View/TemplatePaths.php +++ b/src/View/TemplatePaths.php @@ -41,10 +41,19 @@ */ class TemplatePaths { - public const DEFAULT_FORMAT = 'html'; + /** + * @deprecated will be removed with Fluid v5 + */ public const DEFAULT_TEMPLATES_DIRECTORY = 'Resources/Private/Templates/'; + /** + * @deprecated will be removed with Fluid v5 + */ public const DEFAULT_LAYOUTS_DIRECTORY = 'Resources/Private/Layouts/'; + /** + * @deprecated will be removed with Fluid v5 + */ public const DEFAULT_PARTIALS_DIRECTORY = 'Resources/Private/Partials/'; + public const DEFAULT_FORMAT = 'html'; public const CONFIG_TEMPLATEROOTPATHS = 'templateRootPaths'; public const CONFIG_LAYOUTROOTPATHS = 'layoutRootPaths'; public const CONFIG_PARTIALROOTPATHS = 'partialRootPaths'; @@ -103,6 +112,10 @@ class TemplatePaths protected string $format = self::DEFAULT_FORMAT; + /** + * @deprecated will be removed with Fluid v5; appropriate setters (like setTemplateRootPaths()) + * should be called instead + */ public function __construct(array|string|null $packageNameOrArray = null) { if (is_array($packageNameOrArray)) { @@ -112,8 +125,13 @@ public function __construct(array|string|null $packageNameOrArray = null) } } + /** + * @deprecated will be removed in Fluid v5; use the individual getters instead. Sanitation is not necessary + * because setters already sanitize input values + */ public function toArray(): array { + trigger_error('toArray() has been deprecated and will be removed in Fluid v5.', E_USER_DEPRECATED); return [ self::CONFIG_TEMPLATEROOTPATHS => $this->sanitizePaths($this->getTemplateRootPaths()), self::CONFIG_LAYOUTROOTPATHS => $this->sanitizePaths($this->getLayoutRootPaths()), @@ -327,9 +345,12 @@ protected function resolveFilesInFolder(string $folder, string $format): array * Will replace any currently configured paths. * * @api + * @deprecated will be removed with Fluid v5; appropriate setters (like setTemplateRootPaths()) + * should be called instead */ public function fillFromConfigurationArray(array $paths): void { + trigger_error('fillFromConfigurationArray() has been deprecated and will be removed in Fluid v5.', E_USER_DEPRECATED); list($templateRootPaths, $layoutRootPaths, $partialRootPaths, $format) = $this->extractPathArrays($paths); $this->setTemplateRootPaths($templateRootPaths); $this->setLayoutRootPaths($layoutRootPaths); @@ -345,9 +366,12 @@ public function fillFromConfigurationArray(array $paths): void * Will replace any currently configured paths. * * @api + * @deprecated will be removed with Fluid v5; appropriate setters (like setTemplateRootPaths()) + * should be called instead */ public function fillDefaultsByPackageName(string $packageName): void { + trigger_error('fillDefaultsByPackageName() has been deprecated and will be removed in Fluid v5.', E_USER_DEPRECATED); $path = $this->getPackagePath($packageName); $this->setTemplateRootPaths([$path . self::DEFAULT_TEMPLATES_DIRECTORY]); $this->setLayoutRootPaths([$path . self::DEFAULT_LAYOUTS_DIRECTORY]); @@ -409,9 +433,11 @@ protected function ensureAbsolutePath(string $path): string * * @param string[] $reference * @return string[] + * @deprecated will be removed with Fluid v5 */ protected function ensureAbsolutePaths(array $reference): array { + trigger_error('ensureAbsolutePaths() has been deprecated and will be removed in Fluid v5.', E_USER_DEPRECATED); return array_map([$this, 'ensureAbsolutePath'], $reference); } @@ -430,9 +456,12 @@ protected function ensureSuffixedPath(string $path): string * entries being recorded first and plurals second. * * Adds legacy singular name as last option, if set. + * + * @deprecated will be removed with Fluid v5 */ protected function extractPathArrays(array $paths): array { + trigger_error('extractPathArrays() has been deprecated and will be removed in Fluid v5.', E_USER_DEPRECATED); $format = $this->getFormat(); // pre-processing: if special parameters exist, extract them: if (isset($paths[self::CONFIG_FORMAT])) { @@ -456,8 +485,12 @@ protected function extractPathArrays(array $paths): array return $pathCollections; } + /** + * @deprecated will be removed with Fluid v5 + */ protected function getPackagePath(string $packageName): string { + trigger_error('getPackagePath() has been deprecated and will be removed in Fluid v5.', E_USER_DEPRECATED); return ''; }