Skip to content

Commit

Permalink
[TASK] Deprecate TYPO3-specific code in TemplatePaths
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
s2b committed Aug 30, 2024
1 parent 54ea9de commit bb03508
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/View/TemplatePaths.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)) {
Expand All @@ -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()),
Expand Down Expand Up @@ -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);
Expand All @@ -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]);
Expand Down Expand Up @@ -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);
}

Expand All @@ -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])) {
Expand All @@ -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 '';
}

Expand Down

0 comments on commit bb03508

Please sign in to comment.