Skip to content

Add response context support#36

Merged
koertho merged 7 commits intov2from
feature/response_context
Apr 21, 2026
Merged

Add response context support#36
koertho merged 7 commits intov2from
feature/response_context

Conversation

@koertho
Copy link
Copy Markdown
Contributor

@koertho koertho commented Apr 21, 2026

This PR add custom response context bag for entries
It also adjust the way how entries injected in modern layouts due defered rendering.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for collecting encore entrypoints via Contao’s ResponseContext (with an EntryBag), and updates entry injection to work with deferred rendering in modern layouts.

Changes:

  • Introduces HeimrichHannot\EncoreBundle\Request\ResponseContext\Entry + EntryBag and wires them into FrontendAsset/EntryPointsBuilder.
  • Updates listeners (InjectPageEntriesListener, ReplaceDynamicScriptTagsListener) to use ResponseContextAccessor instead of FrontendAsset.
  • Updates docs, twig collector template styling, phpstan baseline, and adds/adjusts tests for the new behavior.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/EventListener/InjectPageEntriesListenerTest.php Adds coverage for deferred loading via response_context and “regular page” early return.
tests/EventListener/Contao/ReplaceDynamicScriptTagsListenerTest.php Updates test to pass ResponseContext into the builder via ResponseContextAccessor.
tests/EntryPoint/EntryPointsBuilderTest.php Migrates from FrontendAsset to ResponseContext/EntryBag and asserts new behavior.
tests/Asset/PageEntrypointsTest.php Adapts test setup to new FrontendAsset(ResponseContextAccessor) constructor.
tests/Asset/FrontendAssetTest.php Adds tests for behavior with/without a ResponseContext.
src/Request/ResponseContext/EntryBag.php New container for response-context entry registrations.
src/Request/ResponseContext/Entry.php New DTO for entry registrations (name/origin/extension).
src/EventListener/InjectPageEntriesListener.php Implements deferred injection by wrapping response_context and triggering on end_of_head access.
src/EventListener/Contao/ReplaceDynamicScriptTagsListener.php Switches to response context for building entrypoints.
src/EntryPoint/EntryPointsBuilder.php Adds response-context and “custom bag” sources for building entrypoints.
src/EntryPoint/EntryPoint.php Adds fromEntry() helper for converting EntryEntryPoint.
src/Asset/FrontendAsset.php Reworks active entrypoint tracking to store entries in ResponseContext (EntryBag).
phpstan-baseline.neon Updates baseline counts for additional LayoutEvent accessors usage.
docs/developers/dynamic_entries.md Documents the new response-context approach for registering entries.
docs/developers.md Updates the “custom template” example to use response context/custom bag.
contao/templates/twig/data_collector/huh_encore.html.twig Adjusts table cell styling in the data collector view.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/EventListener/InjectPageEntriesListener.php Outdated
Comment thread docs/developers.md
Comment thread src/EntryPoint/EntryPointsBuilder.php Outdated
Comment thread src/EntryPoint/EntryPointsBuilder.php
@koertho koertho merged commit 53f7d03 into v2 Apr 21, 2026
12 checks passed
@koertho koertho deleted the feature/response_context branch April 21, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants