TermWriter final readonly class
Minn\Runtime\TermWriter · public/minn/src/Minn/Runtime/TermWriter.php · 157 lines
The decisions behind wp_delete_term and the object-term relationships: which relationships to add and remove (saves are Runtime\TermSave). The rows themselves come from Content\Terms; the lifecycle actions fire from here in the reference's order. Behaviour pinned by contracts/fixtures/api/content.json.
Constants and properties
| private | readonly Minn\Db $db | Promoted from the constructor. |
| private | readonly Minn\Content\Terms $terms | Promoted from the constructor. |
| private | readonly Minn\Runtime\TermQuery $query | Promoted from the constructor. |
| private | readonly Minn\Content\PostWriter $posts | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db, Minn\Content\Terms $terms, Minn\Runtime\TermQuery $query, Minn\Content\PostWriter $posts)# | ||||||||||
| method | delete(array $row, string $taxonomy, bool $hierarchical, int $default): array# | Deletes a term; objects left without a category fall back to the default one. Returns the object ids the term was attached to.
@return list<int> | |||||||||
| method | relate(int $objectId, array $keep, array $old, string $taxonomy, ?Closure $count = NULL): void# | Makes an object's relationships in a taxonomy exactly $keep (or $old plus $keep when appending), in the reference's order: each new relationship between add_term_relationship and added_term_relationship, the counts of those terms, then the ones that went, between delete_term_relationships and deleted_term_relationships, and their counts. $count recounts a list of term_taxonomy ids and tells plugins (wp_update_term_count); without it the taxonomy is recounted quietly.
| |||||||||
| method | unrelate(int $objectId, array $ttIds, string $taxonomy, ?Closure $count = NULL): bool# | Removes the given relationships between delete_term_relationships and deleted_term_relationships, then recounts those terms; true when any row went.
| |||||||||
| method | publishedCount(int $ttId, array $statuses = array ( 0 => 'publish', )): int# | How many objects in the counted statuses a term holds, as the stored count keeps it (published ones unless a plugin widens the list).
| |||||||||
| method | split(int $termId, int $ttId): ?array# | Gives a taxonomy row that shares its term with another taxonomy a term of its own (the same name, slug and group), and moves its children under it. Null when no other taxonomy holds the term. @return array{0: int, 1: string, 2: list<int>}|null the new term id, the taxonomy, the children moved | |||||||||
| method | relationshipCount(int $ttId): int# | Every object filed under a term, whatever it is: the count a taxonomy of links or other non-posts keeps. | |||||||||
| method | storeCount(int $ttId, int $count): void# | Stores a term's count. | |||||||||
| method | termIdsOf(array $ttIds): array# | The term ids behind term_taxonomy ids, as stored (strings), in the order given. @param list<int> $ttIds @return list<string>
|
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | ttIdOf(int $termId, string $taxonomy): int# |
Nothing matches.