API / Minn\Rest / FontCollectionsController

FontCollectionsController final readonly class

Minn\Rest\FontCollectionsController · public/minn/src/Minn/Rest/FontCollectionsController.php · 78 lines

wp/v2/font-collections (probe: the font library routes on the reference): the collections registered with the font library, in the order they were registered, a page at a time, and one by its slug. Only someone who may edit theme options reads them, refused as rest_cannot_read. A collection shows its slug, then its name, description, font families and categories as its data holds them, the same in every context, through rest_prepare_font_collection. The reference registers a Google Fonts collection read from wordpress.org; the engine registers none of its own (wp-api/fonts.php), so the list holds what plugins register.

Used by 1

Constants and properties

privateREFUSAL = 'Sorry, you are not allowed to access font collections.'
privateFIELDS = array ( 0 => 'name', 1 => 'description', 2 => 'font_families', 3 => 'categories', )
privatereadonly Minn\Rest\RestUrl $url

Promoted from the constructor.

Public

new__construct(Minn\Rest\RestUrl $url)#
methodlist(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/font-collections (cap edit_theme_options)#

The registered font collections, a page at a time.

methodsingle(Minn\Http\Request $request, string $slug): Minn\Http\ResponseGET /wp/v2/font-collections/{slug:[\/\w-]+} (cap edit_theme_options)#

One registered font collection, by its slug.

Internals 2

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatecollections(): array#

The collections registered with the font library (WP_Font_Library), which keeps its one instance on the runtime; none before anything registers one.

@return array<string, object>
privateitem(object $collection, array $data): array#

A collection as wp/v2 shapes it, through rest_prepare_font_collection.

$dataarray<string, mixed>
@return array<string, mixed>