refactor!: configure default template in code instead of rex_config#6535
Merged
Conversation
Templates are code (not DB) since 6.x, so the default template no longer belongs in rex_config. Replace the "default_template" config setting and its backend dropdown with Template::setDefault(MyTemplate::class), to be called in the project boot() method. When no default is set, the first available template is used.
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.
Why
Templates are code (not DB) since 6.x, so the default template no longer belongs in
rex_config. Thedefault_templateconfig setting and its backend dropdown in the system settings have become inconsistent with that model.What
default_templateconfig setting withTemplate::setDefault(MyTemplate::class), meant to be called in the project'sboot()method. It takes the FQCN (autocomplete-friendly) and throws if the class is not a registered template.Template::getDefaultKey()returns the key of the configured default; when none is set it falls back to the first available template — which covers the common case of a single template nicely. Returnsnullonly when no templates exist at all.default_templatesetting handling and the select field frompages/system/settings.phpplus the related lang strings.CategoryHandler(the per-category fallback stays, since the global default may not be allowed in a given category).Breaking change
The
default_templateconfig key and its system setting UI are gone. Projects must set their default template in code viaTemplate::setDefault(...)instead.