diff --git a/Build/phpstan-baseline.neon b/Build/phpstan-baseline.neon index 44524de4f..0a7060dab 100644 --- a/Build/phpstan-baseline.neon +++ b/Build/phpstan-baseline.neon @@ -1,5 +1,15 @@ parameters: ignoreErrors: + - + message: "#^Call to function method_exists\\(\\) with 'TYPO3\\\\\\\\CMS\\\\\\\\Core\\\\\\\\Utility\\\\\\\\PathUtility' and 'getPublicResourceWe…' will always evaluate to true\\.$#" + count: 1 + path: ../Classes/DataProcessing/StaticFilesProcessor.php + + - + message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\PathUtility::getPublicResourceWebPath\\(\\).$#" + count: 1 + path: ../Classes/DataProcessing/StaticFilesProcessor.php + - message: """ diff --git a/Classes/DataProcessing/StaticFilesProcessor.php b/Classes/DataProcessing/StaticFilesProcessor.php index a05e44699..d39972028 100644 --- a/Classes/DataProcessing/StaticFilesProcessor.php +++ b/Classes/DataProcessing/StaticFilesProcessor.php @@ -11,11 +11,12 @@ use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; /** - * This processor generates a set of file objects. + * This processor generates a set of file objects (deprecated) or URIs. * * 10 = BK2K\BootstrapPackage\DataProcessing\StaticFilesProcessor * 10 { @@ -24,6 +25,7 @@ * 1 = EXT:bootstrap_package/Resources/Public/Images/Icons/icon-1.png * circle = EXT:bootstrap_package/Resources/Public/Images/Icons/icon-circle.png * } + * compatibilityMode = false * as = staticFiles * } */ @@ -55,15 +57,31 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu } } - // Get file objects + // Get file objects (deprecated) or URI for each file $images = []; if (count($files) !== 0) { - $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); + // @todo: compat fallback, will be removed with v13 + $resourceFactory = null; + if ($this->isCompatibilityMode($processorConfiguration)) { + trigger_error( + 'The resolvement to FILE objects is deprecated and will stop working in Bootstrap Package 13.0. Change your Fluid templates properly and set "compatibilityMode" to "false".', + E_USER_DEPRECATED + ); + $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); + } + foreach ($files as $key => $file) { $absFilename = GeneralUtility::getFileAbsFileName($file); if (file_exists($absFilename)) { - // Do not use absolute file name to ensure correct path resolution from ResourceFactory. - $images[$key] = $resourceFactory->retrieveFileOrFolderObject($file); + if ($resourceFactory instanceof ResourceFactory) { + // @todo: compat fallback, will be removed with v13 + // Do not use absolute file name to ensure correct path resolution from ResourceFactory. + $images[$key] = $resourceFactory->retrieveFileOrFolderObject($file); + } elseif (str_starts_with($file, 'EXT:') && method_exists(PathUtility::class, 'getPublicResourceWebPath')) { + $images[$key] = PathUtility::getPublicResourceWebPath($file); + } else { + $images[$key] = PathUtility::getAbsoluteWebPath($absFilename); + } } } } @@ -78,4 +96,13 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu return $processedData; } + + /** + * @param array $processorConfiguration The configuration of this processor + * @return bool + */ + private function isCompatibilityMode(array $processorConfiguration) + { + return !isset($processorConfiguration['compatibilityMode']) || $processorConfiguration['compatibilityMode'] !== 'false'; + } } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 9a0215f22..4f4e06cd1 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -236,6 +236,7 @@ page { normal = {$page.logo.file} inverted = {$page.logo.fileInverted} } + compatibilityMode = false as = logo } } diff --git a/Resources/Private/Partials/Page/Header/Logo.html b/Resources/Private/Partials/Page/Header/Logo.html index cc2d9d83d..79358368e 100644 --- a/Resources/Private/Partials/Page/Header/Logo.html +++ b/Resources/Private/Partials/Page/Header/Logo.html @@ -2,9 +2,9 @@ - {logoAlt} + {logoAlt} - {logoAlt} + {logoAlt}