TermQuery final readonly class
Minn\Runtime\TermQuery · public/minn/src/Minn/Runtime/TermQuery.php · 376 lines
Term reads in the shapes plugin code asks for: get_terms() arguments to rows, the tree filters (child_of, exclude_tree), the fields shapes, and the single-term lookups. Behaviour pinned by contracts/fixtures/api/content.json.
Constants and properties
| const | DEFAULTS = array ( 'taxonomy' => NULL, 'object_ids' => NULL, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true, 'include' => array ( ), 'exclude' => array ( ), 'exclude_tree' => array ( ), 'number' => '', 'offset' => '', 'fields' => 'all', 'count' => false, 'name' => '', 'slug' => '', 'term_taxonomy_id' => '', 'hierarchical' => true, 'search' => '', 'name__like' => '', 'description__like' => '', 'pad_counts' => false, 'get' => '', 'child_of' => 0, 'parent' => '', 'childless' => false, 'cache_domain' => 'core', 'update_term_meta_cache' => true, 'meta_query' => '', 'meta_key' => '', 'meta_value' => '', ) | |
| private | COLUMNS = 't.term_id, t.name, t.slug, t.term_group, tt.term_taxonomy_id, tt.taxonomy, tt.description, tt.parent, tt.count' | |
| private | readonly Minn\Db $db | Promoted from the constructor. |
| private | readonly Closure $slug | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db, Closure $slug)# |
| |||
| method | row(int $termId, ?string $taxonomy): ?array# | A term row joined with its taxonomy row, by id (and taxonomy when known). @return array<string, mixed>|null @return array<string, mixed>|null | |||
| method | find(string $field, mixed $value, ?string $taxonomy): ?array# | The term id and taxonomy a field value names; null when nothing matches or the field is not one a term can be found by. @return array{term_id: int, taxonomy: string}|null | |||
| method | exists(string|int $term, ?string $taxonomy, ?int $parent): ?array# | Whether a term (by id, or by slug or name) exists, optionally under a taxonomy and parent; the ids when it does. @return array{term_id: int, term_taxonomy_id: int}|null | |||
| method | lookup(string $field, string $value, ?string $taxonomy, ?int $parent): ?array# | The term whose slug or name (as stored) is exactly the value, optionally in a taxonomy and under a parent (0 for the top level). @return array{term_id: int, term_taxonomy_id: int}|null | |||
| method | hasChildren(int $parent, ?array $taxonomies): bool# | Whether any term in the taxonomies (any taxonomy for null) sits under the parent: the reference answers a lookup under a childless parent with nothing before it looks.
| |||
| method | slugTaken(string $slug, int $exceptTermId): bool# | Whether a term other than the one named holds the slug, in any taxonomy. | |||
| method | normalise(array $args): array# | get_terms() arguments normalised: the "get all" shortcut, integer lists, sanitised slugs. | |||
| method | rows(array $args, ?array $taxonomies): array# | The term rows the arguments match, ordered and paged, with the tree filters applied.
@return list<array<string, mixed>> | |||
| method | hierarchy(string $taxonomy): array# | Every parent in a taxonomy that has children, mapped to its children's ids. A taxonomy nobody nested reads as an empty map. @return array<int, list<int>> | |||
| method | children(int $termId, string $taxonomy): array# | Every term id under a term, however deep. @return list<int> @return list<int> | |||
| method | objectsIn(array $termIds, array $taxonomies, string $order): array# | The object ids attached to any of the terms in any of the taxonomies. @param list<int> $termIds @param list<string> $taxonomies @return list<int>
|
Internals 7
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | readRow(int $termId, ?string $taxonomy): ?array# | @return array<string, mixed>|null | |||
| private | idList(mixed $value): array# | A comma list, array, or blank as positive ids. @return list<int> @return list<int> | |||
| private | descendants(array $rows, int $root): array# | The rows under a term, however deep, in source order. @param list<array<string, mixed>> $rows @return list<array<string, mixed>>
| |||
| private | where(array $args, ?array $taxonomies): array# | @return array{0: string, 1: string, 2: list<mixed>} the join, the WHERE clause, its parameters | |||
| private | metaClauses(array $args): array# | @return list<array{key: string, value?: mixed}> | |||
| private | ids(mixed $list): array# | @return list<int> | |||
| private | like(string $needle): string# |
Nothing matches.