PatternDirectoryController final readonly class
Minn\Rest\PatternDirectoryController · public/minn/src/Minn/Rest/PatternDirectoryController.php · 120 lines
wp/v2/pattern-directory/patterns (Austin, 2026-10-21, decision 1B): the block editor's pattern directory, asked of wordpress.org through the Minn update service, with the query the reference sends upstream (its paging and order, then the search, slugs and offset asked for, the reader's locale, the WordPress version, then the category and keyword by their upstream names). An answer is kept an hour in the site transient the reference keeps it in, named for that query, so either stack reads the other's. Anyone who may edit posts browses it. Each pattern shows its title as the directory renders it, its markup, its category and keyword slugs, its description, viewport width and block types.
Constants and properties
| private | REFUSAL = 'Sorry, you are not allowed to browse the local block pattern directory.' | |
| private | ARGS = array ( 'context' => array ( 'description' => 'Scope under which the request is made; determines fields present in response.', 'type' => 'string', 'enum' => array ( 0 => 'view', 1 => 'embed', 2 => 'edit', ), 'default' => 'view', 'required' => false, ), 'page' => array ( 'description' => 'Current page of the collection.', 'type' => 'integer', 'default' => 1, 'minimum' => 1, 'required' => false, ), 'per_page' => array ( 'description' => 'Maximum number of items to be returned in result set.', 'type' => 'integer', 'default' => 100, 'minimum' => 1, 'maximum' => 100, 'required' => false, ), 'search' => array ( 'description' => 'Limit results to those matching a string.', 'type' => 'string', 'minLength' => 1, 'required' => false, ), 'category' => array ( 'description' => 'Limit results to those matching a category ID.', 'type' => 'integer', 'minimum' => 1, 'required' => false, ), 'keyword' => array ( 'description' => 'Limit results to those matching a keyword ID.', 'type' => 'integer', 'minimum' => 1, 'required' => false, ), 'slug' => array ( 'description' => 'Limit results to those matching a pattern (slug).', 'type' => 'array', 'required' => false, ), 'offset' => array ( 'description' => 'Offset the result set by a specific number of items.', 'type' => 'integer', 'required' => false, ), 'order' => array ( 'description' => 'Order sort attribute ascending or descending.', 'type' => 'string', 'default' => 'desc', 'enum' => array ( 0 => 'asc', 1 => 'desc', ), 'required' => false, ), 'orderby' => array ( 'description' => 'Sort collection by post attribute.', 'type' => 'string', 'default' => 'date', 'enum' => array ( 0 => 'author', 1 => 'date', 2 => 'id', 3 => 'include', 4 => 'modified', 5 => 'parent', 6 => 'relevance', 7 => 'slug', 8 => 'include_slugs', 9 => 'title', 10 => 'favorite_count', ), 'required' => false, ), ) | |
| private | FAILED = 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/forums/">support forums</a>.' | |
| private | KEEP = 3600 | How long an answer is kept, as the reference keeps it. |
| private | readonly Minn\Http $http | Promoted from the constructor. |
Public
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | upstreamQuery(array $asked): array# | The upstream query in the reference's order: paging and order first, then the search, slugs and offset the request names, the reader's locale and the WordPress version, then category and keyword under their upstream names.
@return array<string, mixed> | |||
| private | fetch(array $query): array# | The directory's answer, its patterns as objects. A request that never got an answer is refused with the transport's own error; an answer that is not a list of patterns as pattern_api_failed, the body beside it, as the reference refuses both.
@return list<object> | |||
| private | item(object $raw): array# | One pattern as the directory route shows it. @return array<string, mixed> |
Nothing matches.