Bug #89445
closed
FooterAsset are not loaded
Added by Michal Majernik about 5 years ago.
Updated almost 5 years ago.
Category:
Content Rendering
Tags:
footer assets, fluid
Description
Assets in the FooterAssets section are no longer rendered.
How to reproduce:¶
Create a simple indexAction, Index.html template and a simple js file (i.e. feature.js)
When you add FooterAssets section into your Index.html template as follows:
<f:section name="FooterAssets">
<script type="application/javascript" src="{f:uri.resource(path:'JavaScript/feature.js', extensionName: 'MyExtension')}"></script>
</f:section>
then this javascipt won't be rendered
- Status changed from New to Accepted
- Is Regression set to Yes
Hi Michal,
thanks for reporting. I could verify the issue.
It seems related to the newly introduced Dependency Injection and the initialization of the PageRenderer class in the ActionController.
If you need a quick fix, you can override the method in your controller with the following:
protected function renderAssetsForRequest($request)
{
if (!$this->view instanceof TemplateView) {
return;
}
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$variables = ['request' => $request, 'arguments' => $this->arguments];
$headerAssets = $this->view->renderSection('HeaderAssets', $variables, true);
$footerAssets = $this->view->renderSection('FooterAssets', $variables, true);
if (!empty(trim($headerAssets))) {
$pageRenderer->addHeaderData($headerAssets);
}
if (!empty(trim($footerAssets))) {
$pageRenderer->addFooterData($footerAssets);
}
}
- Assignee set to Benjamin Franzke
After talking to Benjamin we figured out, that indeed makeInstance and OM->get() return different objects here
$pageRenderer = $this->objectManager->get(PageRenderer::class);
spl_object_id($pageRenderer); // 946
spl_object_hash($pageRenderer); // 000000002101b3d70000000020f34487
$pageRenderer2 = GeneralUtility::makeInstance(PageRenderer::class);
spl_object_id($pageRenderer2); // 1045
spl_object_hash($pageRenderer2); // 000000002101b3d70000000020f34487
The reason is that TSFE sets a PageRendererInstance via setSingletonInstance()
which is then only respected by instantiantion via GU::makeInstance()
.
The symfony DI container and therefore the ObjectManager do not now anything about this singleton cache.
The goal is to remove setSingletonInstance()
from usage outside of tests completely.
- Related to Feature #88689: Support for system-wide class dependency injection, PSR-11 added
- Related to Bug #68061: Ensure PageRenderer singleton is set added
- Status changed from Accepted to Under Review
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Related to Bug #87402: Feature-79409 renderAssetsForRequest does not work for USER_INT/uncached added
- Status changed from Resolved to Closed
Also available in: Atom
PDF