Feature: #91715 - Add multiple has($identifier) methods to \TYPO3\CMS\Core\Page\AssetCollector¶
See forge#91715
Description¶
The new feature can check if the assets such as JavaScript, inline stylesheets, stylesheets, and media already exist before generating it again.
To accomplish this, new methods has been added to \TYPO3\
:
has
Java Script (string $identifier): bool has
Inline Java Script (string $identifier): bool has
Style Sheet (string $identifier): bool has
Inline Style Sheet (string $identifier): bool has
Media (string $identifier): bool
//use TYPO3\CMS\Core\Page\AssetCollector;
//use TYPO3\CMS\Core\Utility\GeneralUtility;
$assetsCollector = GeneralUtility::makeInstance(AssetCollector::class);
if ($assetsCollector->hasJavaScript($identifier)) {
// result: true - javascript with identifier $identifier exists
} else {
// result: false - javascript with identifier $identifier do not exists
}
// $result<X> is true if $identifier exists, otherwise false.
$result1 = $assetsCollector->hasJavaScript($identifier);
$result2 = $assetsCollector->hasInlineJavaScript($identifier);
$result3 = $assetsCollector->hasStyleSheet($identifier);
$result4 = $assetsCollector->hasInlineStyleSheet($identifier);
$result5 = $assetsCollector->hasMedia($identifier);
Copied!
Impact¶
Users have the ability to check if the asset already exists before regenerating it, thus avoiding redundancy.