#91715Make new AssetCollector class searchable
Description
Sometimes the generation of inline code is quite heavy and one wants to avoid doing it multiple times. In my opinion, the class “TYPO3\CMS\Core\Page\AssetCollector” from TYPO3 10+ should have methods to query the internal status of the class.
The existence of a generated inline JavaScript could be asked by using a hypothetical “hasInlineJavaScript(string $identifier): bool” method, thus avoiding to generate it again when used multiple times during the same request.
An analog method “getInlineJavaScript” could also be of some use, but I still didn’t found any advantage for it.
Possible implementation of proposed methods:
public function hasInlineJavaScript(string $identifier): bool
{
return isset($this->inlineJavaScripts[$identifier]);
}
public function getInlineJavaScript(string $identifier): ?array
{
return $this->inlineJavaScripts[$identifier] ?? null;
}