MediaObject final readonly class
Minn\Rest\MediaObject · public/minn/src/Minn/Rest/MediaObject.php · 171 lines
The wp/v2 media object, view and edit context.
Constants and properties
| private | readonly Minn\Content\Posts $posts | Promoted from the constructor. |
| private | readonly Minn\Media\Uploads $uploads | Promoted from the constructor. |
| private | readonly Minn\Front\Permalinks $permalinks | Promoted from the constructor. |
| private | readonly Minn\Rest\RestUrl $url | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
| private | readonly Minn\Rest\Types $types | Promoted from the constructor. |
Public
| new | __construct(Minn\Content\Posts $posts, Minn\Media\Uploads $uploads, Minn\Front\Permalinks $permalinks, Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller, Minn\Rest\Types $types)# | |
| method | build(Minn\Content\PostRecord $p, Minn\Rest\Context $context): array# | An attachment in the context asked for, as rest_block_hooks_post_types has it (attachments only when a plugin lists them), through rest_prepare_attachment when a plugin hooks it. |
| method | url(): Minn\Rest\RestUrl# | The REST URL builder. |
| method | links(Minn\Content\PostRecord $p, Minn\Rest\Context $context): array# | The attachment's links in a context: itself (with the methods the caller may use), its collection and type, its author, replies, the post it is attached to, and in the edit context the actions the caller may take; curies when any rel is the API's own. @return array<string, list<array<string, mixed>>> |
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | buildFields(Minn\Content\PostRecord $p, Minn\Rest\Context $context): array# | The wp/v2 media shape, with the edit-context fields when asked. | |||
| private | details(array $meta, string $mime, string $attached): array# | media_details: the stored metadata as it is, its sizes each with its MIME type and URL, and the full size after them when there are any (an attachment without sizes, audio among them, has an empty object).
@return array<string, mixed> |
Nothing matches.