Description
When calling encore_entry_link_tags()
in a Twig template, the underlying PHP code has some safe-guarding in place to ensure the same link tag isn't outputted twice:
webpack-encore-bundle/src/Asset/EntrypointLookup.php
Lines 84 to 89 in 5e1cab3
I'm not entirely sure of the rationale behind this, but it causes an issue when encore_entry_link_tags()
is called twice in the same request.
This issue came to light when investigating why an order confirmation page of a website wasn't outputting a stylesheet's link
tag. After some debugging I figured out it was because the controller for this page sends a confirmation email with an attached PDF which is rendered via HTML/Twig.
The Twig template for the PDF called encore_entry_link_tags()
, so when the confirmation page was loaded and encore_entry_link_tags()
was called a second time, nothing was returned.
I have worked around this by calling the reset()
method of the EntrypointLookup
object right after the confirmation email is sent but it feels like a bit of a hack.
Why does the "make sure to not return the same file multiple times" code need to be there? Can it be removed, or can the issue it solves be solved in a different way?
Relevant Slack discussion: https://symfony-devs.slack.com/archives/C5VHNHY11/p1562584991057800