Skip to content

13B: Notices split into a writer and a presenter - #22

Open
nikolaystrikhar wants to merge 2 commits into
13-activationfrom
13A-notices-split
Open

13B: Notices split into a writer and a presenter#22
nikolaystrikhar wants to merge 2 commits into
13-activationfrom
13A-notices-split

Conversation

@nikolaystrikhar

Copy link
Copy Markdown
Contributor

What: Notices\Queue splits into Notices\Writer (words a notice, stores it under slug:type, behind the new Writer_Interface) and Notices\Presenter (the activate_plugins gate and the render-then-clear, bound by class name); Absorber::notices() returns the writer and Absorber::render_notices() resolves the presenter.

Usage:

// Reword every notice without touching where they are kept or how they are drawn.
$container->singleton( Writer_Interface::class, My_Notice_Writer::class );

Why this way:

The name was wrong and the class was two jobs. Queue never held the queue — Store does — and it answered both "what does this notice say" and "who may see the pending set, and is it gone once they have". A host already running its own notices library has an opinion about the first and none about the second.

Only the writer earns a contract. Nothing in the library dispatches on how a notice reaches the screen: the all_admin_notices trampoline is the presenter's only caller, so a host that wants none of our rendering takes that callback off rather than binding an implementation that does nothing.

The capability check goes with render-and-clear, not with the markup. It guards the clearing as much as the drawing, so deciding those separately would let a user who may not see the queue destroy it anyway, through a class that never checked.

No behaviour changes. It is a move, which is why it exceeds the usual source-file cap.

Notices\Queue was two jobs and a wrong name. It never held the queue -- Store
does -- and it answered both "what does this notice say" and "who may see the
pending set, and is it gone once they have". Those change for different reasons,
and a host already running its own notices library has an opinion about the first
and none about the second.

Notices\Writer takes Store and words the notices, behind Writer_Interface, which
is what a host rebinds. Notices\Presenter takes Store and Renderer and does the
render-then-clear, with the activate_plugins gate that gua...(truncated)
@nikolaystrikhar nikolaystrikhar changed the title 13A: Notices split into a writer and a presenter 13B: Notices split into a writer and a presenter Aug 13, 2026
Every new PHP file declares strict_types, so the rule arrives with the file
rather than as a sweep over it afterwards. PR 21 covers everything that already
existed on main.

The three files this branch renames count as new here. Writer, Writer_Interface
and Spy_Writer are new paths that main has never carried, so waiting for the
rename to inherit the declare from the file it came from would leave them
without one for as long as PR 21 is unmerged -- and leave Presenter, added
outright beside them, declaring it already.

@d4mation d4mation 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.

I don't know if I'm 100% sold on the name Presenter, but I do agree with the overall split of concerns :)

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.

2 participants