Skip to content

feat: render documents through the view renderer seam - #11

Merged
tyrsson merged 4 commits into
1.0.xfrom
tyrsson-render-03-seam
Nov 13, 2026
Merged

tyrsson merged 4 commits into
1.0.xfrom
tyrsson-render-03-seam

Conversation

@tyrsson

@tyrsson tyrsson commented Nov 13, 2026

Copy link
Copy Markdown
Member

Scope

Phase 3 of specs/001-document-view-render/tasks.md: T015 to T027, User Story 1, the rendering seam.

DocumentViewRenderer implements League\CommonMark\Renderer\NodeRendererInterface and is registered for League\CommonMark\Node\Block\Document at priority 10 in EnvironmentFactory. The body is obtained once from the injected ChildNodeRendererInterface and handed to LaminasViewRenderer, so the layout wrap, the view helpers and the helper state reset all stay with the framework. HtmlRenderer, MarkdownConverter and MarkdownConverterInterface are untouched.

Tasks

Task Change
T015 test/unit/DocumentViewRendererTest.php
T016 test/unit/DocumentViewRendererFactoryTest.php
T017 templates/commondoc/layout.phtml
T018 src/View/DocumentViewRenderer.php
T019 src/Container/DocumentViewRendererFactory.php
T020 src/ConfigProvider.php view config, factories and bus pipeline
T021 src/Container/EnvironmentFactory.php renderer and pre-render listener
T022 templates/commondoc/document.phtml as the body template
T023 LayoutWrappingMiddleware, its factory and both unit tests deleted
T024 test/unit/ConfigProviderTest.php
T025 test/integration/ConfigProviderWiringTest.php, test/integration/ContainerBootTest.php
T026 test/unit/EnvironmentFactoryTest.php
T027 test/integration/DocumentViewRenderingTest.php

Behaviour

  • The body template is commondoc::document, receives documentBody, and never sets content.
  • page arrives on the render root, so a render with no page still works; the template reads it behind a null check.
  • templates.map holds both addresses, so a site overrides the body by adding the same address to its own map, with no code change. Resolution order is unchanged: theme 100, map 50, path stack 1.
  • The dead view_manager.template_path_stack key is gone from the provider.

Defect found while testing

config/autoload/commonmark.global.php set external_link.nofollow to 'none', which the CommonMark external link extension rejects; the no-apply value is the empty string. It surfaced only when a document was actually parsed, which nothing did before this phase. Corrected to '' with the comment alongside it.

Gates

  • mago format --check: clean
  • mago lint: no issues
  • mago analyze: no issues, no new baseline entries
  • mago guard: no issues
  • PHPUnit: 92 tests, 160 assertions, all passing

Infection is left to CI on push, as agreed.

tyrsson and others added 2 commits November 12, 2026 19:23
…straint

The document view seam imports Mezzio\Template\TemplateRendererInterface directly, so the package that provides it becomes a direct requirement instead of an accident of webware-theme's tree. The php constraint now covers 8.6 while config.platform.php stays pinned at 8.4.99.

Baseline gates recorded before any code change: mago format --check, lint, analyze and guard exit zero, 43 unit tests and 8 integration tests pass.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Joey Smith <jsmith@webinertia.net>
Page implements Laminas\View\Model\ModelInterface for the state a template
reads, never for a position in the render tree: it is final readonly and every
mutator throws, because LaminasViewRenderer writes to the model it renders and
walks children through beforeRender().

PageContext holds the current page for one conversion. PageContextListener
copies it into the document data under commondoc.page on
DocumentPreRenderEvent, so the renderer reads the page from the document it
belongs to and a document built outside a build simply has no entry.

Both factories are registered in ConfigProvider, and the aliases docblock now
says interface-string because its only key is an interface.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Joey Smith <jsmith@webinertia.net>
@tyrsson
tyrsson force-pushed the tyrsson-render-03-seam branch from e314a6d to 8a3e1fe Compare November 13, 2026 01:39
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

tyrsson and others added 2 commits November 12, 2026 19:45
Page implements ModelInterface and returns an ArrayIterator, so the
IteratorAggregate import was never referenced. Mago reports it as
no-redundant-use on both supported PHP versions, which fails the lint gate
and skips the suites behind it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add DocumentViewRenderer, registered for the document node at priority 10, so a
converted document is rendered as a view instead of as finished HTML. The body
comes from the injected child renderer and is handed to the template renderer
once, which keeps the layout wrap, the view helpers and the helper state reset
with the framework.

- src/View/DocumentViewRenderer.php, src/Container/DocumentViewRendererFactory.php
- templates/commondoc/layout.phtml as the shell, templates/commondoc/document.phtml
  rewritten as the body template reading documentBody and the optional page
- ConfigProvider: templates.map for commondoc::document and commondoc::layout,
  templates.layout, renderer factory entry, middleware pipeline entry removed
- EnvironmentFactory: renderer at priority 10 and the page context listener on
  the pre-render event
- LayoutWrappingMiddleware, its factory and both tests deleted (owner approved)
- config/autoload/commonmark.global.php: external_link.noFollow was 'none',
  which the CommonMark extension rejects; it is now '' (apply to none)

Tests cover T015 to T027: renderer and factory units, layout and body templates,
the provider wiring, the environment factory registrations and a real container
render asserting the site override, the packaged body with the layout wrap and
the template-not-found failure.

Signed-off-by: Joey Smith <jsmith@webinertia.net>
@tyrsson
tyrsson force-pushed the tyrsson-render-03-seam branch from 8a3e1fe to 8d04f86 Compare November 13, 2026 01:45
@tyrsson
tyrsson merged commit 8c8e762 into 1.0.x Nov 13, 2026
12 checks passed
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