ViewConfigPatch final class
Minn\Rest\ViewConfigPatch · public/minn/src/Minn/Rest/ViewConfigPatch.php · 151 lines
A patch to a view configuration (WP_View_Config_Data; probe rest-view-config), applied as the reference applies it. Only schema version 1 is taken, and only the documented keys: each is set (its value replaced), merged (maps merged key by key, lists joined with their members matched by identity), replaced (merged, but lists replaced whole) or removed (keys from a map, members from a list by identity). A null in a patch removes what it names. What a caller got wrong comes back as problems: the function to name and the words.
Constants and properties
| const | KEYS = array ( 0 => 'default_view', 1 => 'default_layouts', 2 => 'view_list', 3 => 'form', ) | |
| private | SHAPE = 'A view configuration patch value must match the shape of the value it patches: a list merges into a list, and an associative array into an associative array.' | |
| private | array $problems | |
| private | readonly bool $replaceLists | Promoted from the constructor. |
Public
| new | __construct(bool $replaceLists)# | |||||||
| static | apply(array $config, array $patch, mixed $version, string $mode): array# | A configuration with a patch applied in a mode (set, merge, replace, remove), and the problems met: [function or null for the mode's own method, words].
@return array{0: array<string, mixed>, 1: list<array{0: ?string, 1: string}>} | ||||||
| static | stripNulls(mixed $value): mixed# | A value with every null in it removed, lists closed up. | ||||||
| static | identity(mixed $item): ?string# | The identity a list member is matched by: a word itself, a map's id or slug; null for none. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | merge(mixed $current, mixed $incoming): mixed# | Incoming merged over current: maps key by key, lists by identity (or replaced), anything else replaced; a mismatched shape is a problem and leaves current. | ||||||
| private | mergeList(array $current, array $incoming): array# |
@return list<mixed> | ||||||
| private | remove(mixed $current, mixed $spec): mixed# | Keys removed from a map (a list of keys, or a key mapped to what to remove inside it); members removed from a list by identity. |
Nothing matches.