Skip to content

Add ViewSpec; plumb namespaces and extension through ViewFactory - #92

Merged
harikt merged 2 commits into
6.xfrom
view-spec
Jul 23, 2026
Merged

Add ViewSpec; plumb namespaces and extension through ViewFactory#92
harikt merged 2 commits into
6.xfrom
view-spec

Conversation

@harikt

@harikt harikt commented Jul 23, 2026

Copy link
Copy Markdown
Member

ViewFactory::newInstance() built each TemplateRegistry with two of its three constructor arguments, dropping $namespaces entirely, and never called setTemplateFileExtension(). Both settings were therefore unreachable through the factory even though TemplateRegistry has supported namespaces since 2.4.0.

The four settings that describe a registry -- map, paths, namespaces, extension -- are grouped into a readonly ViewSpec rather than passed as flat arguments, which interleaved the view registry's settings with the layout registry's and would have made a nine-parameter method.

$view_factory->newInstance(
    $helpers,
    new ViewSpec(map: $view_map, paths: $view_paths),
    new ViewSpec(map: $layout_map, paths: $layout_paths),
);

$helpers stays the first parameter, so newInstance() and newInstance($helpers) are unaffected; only the five-argument positional form breaks, with a TypeError naming the parameter. That keeps the one-line Aura.Html wiring working, as documented in docs/helpers.md.

ViewSpec is readonly with no setters, so the package's rule that setters return void stays universal. Its newRegistry() method builds the corresponding TemplateRegistry, for assembling a View without the factory.

Summary by CodeRabbit

  • New Features

    • Added ViewSpec for configuring template maps, paths, namespaces, and file extensions.
    • Updated view factory setup to accept separate specifications for views and layouts.
    • Template namespaces and custom file extensions are now supported through factory configuration.
  • Breaking Changes

    • Replaced the previous positional registry configuration arguments with optional view and layout specifications.
  • Documentation

    • Added configuration guidance and migration instructions for the updated factory API.
    • Clarified behavior when no view template is selected.

ViewFactory::newInstance() built each TemplateRegistry with two of its
three constructor arguments, dropping $namespaces entirely, and never
called setTemplateFileExtension(). Both settings were therefore
unreachable through the factory even though TemplateRegistry has
supported namespaces since 2.4.0.

The four settings that describe a registry -- map, paths, namespaces,
extension -- are grouped into a readonly ViewSpec rather than passed as
flat arguments, which interleaved the view registry's settings with the
layout registry's and would have made a nine-parameter method.

    $view_factory->newInstance(
        $helpers,
        new ViewSpec(map: $view_map, paths: $view_paths),
        new ViewSpec(map: $layout_map, paths: $layout_paths),
    );

$helpers stays the first parameter, so newInstance() and
newInstance($helpers) are unaffected; only the five-argument positional
form breaks, with a TypeError naming the parameter. That keeps the
one-line Aura.Html wiring working, as documented in docs/helpers.md.

ViewSpec is readonly with no setters, so the package's rule that setters
return void stays universal. Its newRegistry() method builds the
corresponding TemplateRegistry, for assembling a View without the
factory.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@harikt, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 06f501a1-bf49-41e7-9e60-8c276ac97a84

📥 Commits

Reviewing files that changed from the base of the PR and between c37fe12 and f0ecde5.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • docs/templates.md
  • docs/upgrading.md

Walkthrough

ViewSpec is added as a readonly registry configuration object. ViewFactory now accepts separate view and layout specifications, including namespaces and extensions, with tests and documentation covering the new API and upgrade path.

Changes

ViewFactory registry configuration

Layer / File(s) Summary
ViewSpec contract
src/ViewSpec.php, tests/ViewFactoryTest.php
ViewSpec stores readonly map, path, namespace, and extension settings and creates configured TemplateRegistry instances.
Factory wiring and rendering
src/ViewFactory.php, tests/ViewFactoryTest.php, tests/fixtures/bar_template.phtml
ViewFactory::newInstance() accepts separate view and layout ViewSpec objects, preserving the helpers-first argument and routing registry settings independently.
Usage and upgrade documentation
docs/templates.md, docs/upgrading.md, CHANGELOG.md
Documentation describes the new call signature, registry configuration, namespace and extension support, and upgrade behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ViewFactory
  participant ViewSpec
  participant TemplateRegistry
  participant View
  ViewFactory->>ViewSpec: create view and layout registries
  ViewSpec->>TemplateRegistry: apply map, paths, namespaces, extension
  TemplateRegistry-->>ViewFactory: return configured registry
  ViewFactory->>View: attach registries
  View-->>ViewFactory: render view and layout
Loading

Poem

I’m a bunny with a spec in my hat,
Mapping paths where templates sat.
Namespaces hop, extensions shine,
View and layout stay in line.
New registries bloom—what a clever design!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: adding ViewSpec and updating ViewFactory to pass namespaces and extension through.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch view-spec

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Around line 63-71: Qualify ViewSpec in both migration snippets so copied code
resolves the intended class: update CHANGELOG.md lines 63-71 and
docs/upgrading.md lines 70-75 to use the fully qualified Aura\View\ViewSpec
constructor, or add the corresponding import in each snippet.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c2804e91-9e8c-4a36-9d76-4ecef58bcf4e

📥 Commits

Reviewing files that changed from the base of the PR and between 110a184 and c37fe12.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • docs/templates.md
  • docs/upgrading.md
  • src/ViewFactory.php
  • src/ViewSpec.php
  • tests/ViewFactoryTest.php
  • tests/fixtures/bar_template.phtml

Comment thread CHANGELOG.md
@harikt
harikt merged commit ecf618b into 6.x Jul 23, 2026
7 of 8 checks passed
@harikt
harikt deleted the view-spec branch July 23, 2026 13:40
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.

1 participant