Fix engine-mods leaking due to view created twice in templates - #29
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and simplifies the Flare ListView templates and related backend logic, aiming for better template inheritance, more modularity, and improved event handling in query building. The most important changes are summarized below.
Template Refactoring and Simplification:
list_only.html.twig,form_only.html.twig,filter_only.html.twig,pagination_only.html.twig,paginator_only.html.twig) now extend the mainflare_listview.html.twigtemplate, removing duplicate code and centralizing logic. This makes the templates more maintainable and modular [1] [2] [3] [4] [5].Backend Logic Improvements:
createView()method inEngine.phpnow always clones the engine instance, ensuring modifications are isolated and preventing side effects from shared state.createQueryBuilder()method inListQueryDirector.phpnow correctly dispatches and uses theModifyListQueryStructEvent, ensuring that any event-driven modifications to the query structure are applied before building the final query.Code Cleanliness:
Configuration.php, cleaning up the codebase.This pull request refactors how theflare_listview is created and passed to Twig templates, and fixes an issue with event handling in the query builder. The main goals are to ensure theflare_listis only created once and reused across templates, and to correctly dispatch and use events when building queries.Template refactoring and view initialization:
flare_listis only created if not already set, preventing redundant calls toflare.createViewinflare_listview.html.twig(contao/templates/content_element/flare_listview.html.twig).flare_listinitialization from partial templates (form_only.html.twig,list_only.html.twig,paginator_only.html.twig), assuming it is now provided by the parent template (contao/templates/content_element/flare_listview/form_only.html.twig, [1] [2].Engine logic update:
createView()inEngine.phpto always clone the engine instance, simplifying and making view creation more consistent (src/Engine/Engine.php).Event handling and query building:
ListQueryDirector.phpto use the modified event object and ensure the latestqueryStructis used when creating the query builder (src/Query/Executor/ListQueryDirector.php).