Skip to content

docs: document running a processor on read operations (write: true)#2295

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:docs/processor-write-on-read
Jun 11, 2026
Merged

docs: document running a processor on read operations (write: true)#2295
soyuka merged 1 commit into
api-platform:4.3from
soyuka:docs/processor-write-on-read

Conversation

@soyuka

@soyuka soyuka commented Jun 11, 2026

Copy link
Copy Markdown
Member

Gap

Declaring a processor: on a GetCollection (or GET) operation silently does nothing — the processor is never invoked. This trips users up (see api-platform/core#8089) and is currently undocumented.

Why

WriteProcessor only dispatches to a custom processor when the operation's write flag is truthy. For safe HTTP methods (GET/GetCollection) write defaults to false, so the processor is skipped. Setting write: true opts the operation in.

What

New section in core/state-processors.md: Running a Processor on Read (GET) Operations.

  • Explains the write flag default and WriteProcessor dispatch.
  • Shows PHP attribute + YAML examples (the issue used YAML).
  • CQRS framing: processor = command/query handler, provider = read/query side — with write: true a processor serves as the handler for a read operation, completing the CQRS picture already referenced at the top of the page.

Closes api-platform/core#8089

Note: canWrite() / the write flag is semantically "run the processor", not strictly "mutate state" — worth a rename later, but documenting the current behavior first.

Closes api-platform/core#8089 — users declaring processor: on
GetCollection found the processor silently ignored. Root cause:
WriteProcessor skips dispatch when the operation's write flag is
false, which is the default for safe methods (GET/GetCollection).
Setting write: true opts the operation into running the processor,
which doubles as the command/query handler in a CQRS design.
@soyuka soyuka force-pushed the docs/processor-write-on-read branch from 8947159 to e0806c4 Compare June 11, 2026 15:16
@soyuka soyuka merged commit a932d10 into api-platform:4.3 Jun 11, 2026
3 checks passed
@soyuka soyuka deleted the docs/processor-write-on-read branch June 11, 2026 15:56
@soyuka

soyuka commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

we eventually need to rename or alias write to process

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