Skip to content

feat: allow overriding the views of a whole namespace - #6787

Merged
gharlan merged 2 commits into
6.xfrom
view-overrides
Oct 21, 2026
Merged

gharlan merged 2 commits into
6.xfrom
view-overrides

Conversation

@gharlan

@gharlan gharlan commented Oct 21, 2026

Copy link
Copy Markdown
Member

Adds ViewResolver::overrideNamespace(), so a project can replace the views of a whole namespace from one directory instead of registering every class separately. The main use case is using the form system in the frontend with a different CSS framework (UIkit, Tailwind, …):

if (Core::isFrontend()) {
    ViewResolver::overrideNamespace('Redaxo\Core\Form', __DIR__ . '/views/form');
}
  • The view of a class is looked up by its path relative to the namespace (Redaxo\Core\Form\Widget\Input → <dir>/Widget/Input.view.php), sub-namespaces included.
  • Classes without a view file in the directory fall back to their co-located (backend) view. No frontend views are shipped for now.
  • Class and namespace overrides share one registry; the last registration wins.
  • Overrides stay global. An environment parameter was considered but dropped: the environment is fixed per process, so an if (Core::isFrontend()) around the registration is equivalent and clearer.

Follow-up: the submit/abort buttons are still hard-coded markup in Form and can't be overridden yet.

`ViewResolver::overrideNamespace()` maps a namespace to a directory: a class's view is looked up by its path
relative to the namespace and falls back to the co-located view if the directory has none. This lets a project
restyle e.g. all form views from one place. Class and namespace overrides share one registry, the last registration
wins.

Overrides apply globally; to restyle only the frontend, register them under `Core::isFrontend()`.
@gharlan gharlan added this to the REDAXO 6.0 milestone Oct 21, 2026
@rex-bot rex-bot added the feature Additional functionality label Oct 21, 2026
@gharlan
gharlan merged commit 49e6f4c into 6.x Oct 21, 2026
15 checks passed
@gharlan
gharlan deleted the view-overrides branch October 21, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Additional functionality

Development

Successfully merging this pull request may close these issues.

2 participants