Repository navigation
[access] refactor(widget-api): split WidgetApiController widget, tile, placement, news and calendar actions into named steps - #1084
Open
rubenvdlinde wants to merge 4 commits into
Open
rubenvdlinde wants to merge 4 commits into
rubenvdlinde wants to merge 4 commits into
Conversation
…split Assisted-by: ClaudeCode:claude-opus-5-5
…nt, news and calendar actions into named steps Assisted-by: ClaudeCode:claude-opus-5-5
…le and placement actions The action-seed coverage scan reads the requireAction() call next to each seeded action key, so the session guard stays inline. Assisted-by: ClaudeCode:claude-opus-5-5
…parsing beside the controller Keeps WidgetApiController under the class-length ceiling. Assisted-by: ClaudeCode:claude-opus-5-5
rubenvdlinde
requested review from
WilcoLouwerse,
bbrands02 and
rjzondervan
as code owners
November 11, 2026 19:07
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.
What changed
This replaces #1077 with the same split plus one more step: the role widget filter (
AllowedWidgetFilter) and the calendar window parsing (CalendarRangeParser) live in two small final classes beside the controller, which keepsWidgetApiControllerunder the class-length ceiling ofphpmd.xml.Nine
WidgetApiControllerunits read as named steps. Route actions keep their signatures, and every guarded action still carries its literal guard (requireAction($user, '<key>')oractionRefusal(...)/ adeny*call), which both the guard golden and the action-seed coverage scan read.listAvailable→denyListAvailable→AllowedWidgetFilter::filter(no user or nothing configured: every widget; else the widgets with an allowed id, in order).addWidgetkeeps its guard and depth check, then hands the layout tocreatePlacement, whichaddTilenow shares (201, the widget quota as 409, the generic error) instead of two copies of the same catch blocks;contentToPersistreplaces the inline content branch.denyAddWidgetkeeps the session guard, thendenyWidgetChoice(isBlankId,mayAddWidget: dashboard permission, then the role-feature profile, in that order).addTile→mayAddTo,addTileFromRequest;updatePlacement→denyPlacementUpdate(mayStyle, acknowledgement, container depth, in the original order) →updatedPlacement;denyAcknowledgementChange→touchesAcknowledgement.newsItems→effectiveNewsLimit→newsFor(limit range, then view permission);calendarEvents→calendarEventsIn(placement lookup, then view permission) →calendarEventsOf;resolveCalendarRangekeeps its answer shape and asksCalendarRangeParser(required bounds, dates, order, one-year cap, the same three messages).Allowed and refused outcomes are unchanged, every refusal has the same status and body, and every check still runs before the call it guards.
Characterisation tests
tests/Unit/Controller/WidgetApiControllerActionsGoldenTest.phpwas committed first, against the old code, and passes before and after. It pins what each action answers once its caller guard has passed: the available-widget filter (no user, nothing configured, a configured list), every add-widget refusal (missing or empty id, dashboard permission, role filter not asked after a dashboard refusal, container depth and other depth errors) and the exact layout and content handed to the service with the quota / generic mappings, every tile and placement-update outcome (style permission, acknowledgement fields with and without permission, depth, service error), the news limit bounds and default, and every calendar range outcome including the one-year cap, an unknown placement, a non-viewer and a failing calendar backend. Mutation check: disabling the role-feature check on the old code turned the add-widget golden red; restored before committing. The caller guards are pinned by the existingWidgetApiControllerGuardGoldenTest, which passes unchanged.What ran
vendor/bin/phpunit -c phpunit.xml --no-coverage tests/Unit: 2774 tests OK (13 skipped, as on development), including the action-seed coverage scan.vendor/bin/phpcsandvendor/bin/phpstan analyseon the touched lib files: clean.vendor/bin/phpmdon the touched lib files: one finding,TooManyMethods(37 methods against a limit of 25), the cost of turning long methods into named private steps;composer phpmdis already red on development for other classes.Figures (touched files
lib/Controller/WidgetApiController.php,AllowedWidgetFilter.php,CalendarRangeParser.php)addWidget(six route parameters),addTileandupdatePlacement(the literal guard) stay a little over 15 lines.AllowedWidgetFilterdepends onRoleFeaturePermissionService(already used by the controller); only the controller depends on the two new classes. App-wide: unit complexity 4.02 → 4.16, unit size 3.40 → 3.43, duplication 4.54 → 4.56, unit interfacing 3.14 → 3.15.Maintainability floor: compare against development holds.
AI-assisted: prepared with Claude Code (claude-opus-5-5); reviewed by a maintainer before merge.
Generated by Claude Code