API / Minn\Content / Links

Links final readonly class

Minn\Content\Links · public/minn/src/Minn/Content/Links.php · 102 lines

The links manager's table, as get_bookmarks and wp_insert_link read and write it (probe plugin-queue4). A query narrows by the ids included (which set aside every other narrowing), the ids excluded, the link categories (joined, so a link filed under two of them comes back twice, with the join's columns), visibility and a search over the address, name and description; it sorts by one or more of the link's columns (name when none is known), ascending unless told otherwise.

Uses 1

Constants and properties

constFIELDS = array ( 0 => 'link_id', 1 => 'link_url', 2 => 'link_name', 3 => 'link_image', 4 => 'link_target', 5 => 'link_description', 6 => 'link_visible', 7 => 'link_owner', 8 => 'link_rating', 9 => 'link_updated', 10 => 'link_rel', 11 => 'link_notes', 12 => 'link_rss', )

The columns a link row holds, in the table's order.

privateORDERS = array ( 'name' => 'link_name', 'url' => 'link_url', 'rating' => 'link_rating', 'id' => 'link_id', 'owner' => 'link_owner', 'visible' => 'link_visible', 'updated' => 'link_updated', 'notes' => 'link_notes', 'description' => 'link_description', 'rel' => 'link_rel', 'target' => 'link_target', 'image' => 'link_image', 'rss' => 'link_rss', 'length' => 'length', 'rand' => 'RAND()', )
privatereadonly Minn\Db $db

Promoted from the constructor.

Public

new__construct(Minn\Db $db)#
methodfind(int $id): ?array#

A link's row, its values as strings the way the reference reads them. @return array<string, mixed>|null

@return array<string, mixed>|null
methodmatching(array $args, array $categories, int $recentMinutes): array#

The links a get_bookmarks call asks for.

$argsarray<string, mixed>orderby, order, limit, hide_invisible, show_updated, include, exclude, search
$categorieslist<int>link category term ids, empty for any
$recentMinutesinthow recent an update counts as recent, when show_updated asks
@return list<array<string, mixed>>
methodsave(int $id, array $fields): int#

A link written: a new row when the id is 0, else that row's columns set. The id it was written under.

$fieldsarray<string, mixed>columns of FIELDS
methoddelete(int $id): void#

A link's row removed.

Internals 3

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

privatenarrowing(array $args, array $categories): array#
@return array{string, list<mixed>} the WHERE and its parameters when no ids are included
privatestrings(array $row): array#
$rowarray<string, mixed>@return array<string, string|null>
privateids(mixed $list): array#
@return list<int>