| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Allows job payloads to be dispatched and received as typed DTO objects instead of plain arrays, while maintaining full backward compatibility with existing array-based jobs. - `QueueManager::push()` now accepts a DTO object directly, or a plain array paired with an explicit `dtoClass` option - New `Message::getDto()` / `getDtoClass()` to hydrate the payload back into the DTO on the receiving side — `getArgument()` still returns the raw array unchanged - Two hydration styles, matching CakePHP 5.4's own DTO conventions (`#[RequestToDto]`, `SelectQuery::projectAs()`): constructor reflection (with nested DTOs and `#[CollectionOf]`), and a static `createFromArray()` factory - `shouldBeUnique` dedupe hashing now factors in `dtoClass`, so two different DTO types with coincidentally identical data are never treated as duplicates of each other - Fully backward compatible — legacy array-only pushes produce byte-identical message bodies; `getDto()` gracefully returns `null` (never throws) when no DTO was dispatched or the recorded `dtoClass` can no longer be autoloaded
|
|
||
| $dtoClass = $this->getDtoClass(); | ||
| if ($dtoClass === null) { | ||
| return null; |
There was a problem hiding this comment.
This feels like an error condition to me.
Sorry, something went wrong.
Hydrate only the type the job asks for so a tampered queue body cannot choose which class is instantiated. Throw on failure instead of returning null.
Co-authored-by: Mark Story <mark@mark-story.com>
|
Will fix the rector and CS problems in a separate PR |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Allows job payloads to be dispatched and received as typed DTO objects instead of plain arrays, while maintaining full backward compatibility with existing array-based jobs.
Key Features:
Usage:
Note: requires bumping cakephp/cakephp from ^5.1.0 to ^5.4 (needed for ResultSetFactory::hydrateDto() / DtoMapper), plus php from >=8.1 to >=8.2 to match. Since this raises the floor for every existing installation — not just DTO users — this should ship as 3.0.0 off a new 3.x branch rather than a 2.x minor/patch release, with the version bump called out explicitly in the changelog/release notes.