You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fires after phaseThree (routes created) but before phaseFour (positions), passing direct child PageBuilders so fixture code can reference child route paths when building parent content.
Copy file name to clipboardExpand all lines: CLAUDE.md
+86Lines changed: 86 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -400,6 +400,7 @@ PageBuilder
400
400
401
401
PageDataBuilder
402
402
->nested(Closure): void (Closure receives CwaFixtureBuilder with parent context)
403
+
->onRoutesCreated(Closure): self (Closure receives array<PageBuilder> of direct child page builders; called after phaseThree so child route paths are available)
403
404
->getRoute(): ?Route
404
405
405
406
GroupBuilder
@@ -431,11 +432,96 @@ The builder manages persisting in the correct order. Roughly:
431
432
4.`flush()`
432
433
5. Call `RouteGenerator::create()` for all auto-routed entities (parents before children — breadth-first)
433
434
6.`flush()` — routes now have paths
435
+
6.5. Call `onRoutesCreated` callbacks on any `PageDataBuilder` that registered one, passing the child `PageBuilder` instances tracked during `evaluateNested()`. The callback mutates already-persisted entity properties (e.g. sets `HtmlContent.html` with real child paths). Followed by a `flush()` to persist those changes.
434
436
7. Create ComponentPositions and nav-bar links (which may reference routes created in step 5)
435
437
8. Final `flush()`
436
438
437
439
`->getRoute(routeName)` and `PageDataBuilder/PageBuilder->getRoute()` are only valid after step 5 completes. The builder defers all closures to the correct phase internally. Closures registered against GroupBuilder via `->add()` or `->pageDataPosition()` are evaluated in phase 7. The `->nested()` closure is evaluated during phase 5 so parent routes exist before child routes are generated.
438
440
441
+
### `onRoutesCreated` — implementation plan
442
+
443
+
**Use case:** A `PageData` entity has a component whose content must reference child page URLs (e.g. an `HtmlContent` with links to the child pages). Child routes don't exist at entity-creation time, so the content must be set after `phaseThree`.
444
+
445
+
**Required changes in `CwaFixtureBuilder`:**
446
+
447
+
In `evaluateNested()`, record which page refs were registered by each nested closure and store them on the `PageDataBuilder`:
$intro->html = sprintf('<p>Introduction to Topic 1. Chapters: %s</p>', $links);
519
+
// No persist() needed — entity is already managed; flush() in phaseThreePointFive picks it up
520
+
});
521
+
```
522
+
523
+
**Key constraint:** The `HtmlContent` (or any entity updated in the callback) must already be persisted before `onRoutesCreated` fires — i.e. set on the `PageData` entity before passing to `->pageData()` so phaseOne cascades it. The callback only mutates properties on already-managed entities; it does not call `persist()`.
524
+
439
525
### What the builder handles invisibly
440
526
441
527
-`TimestampedDataPersister->persistTimestampedFields($entity, true)` on every entity
0 commit comments