OwnedOneTrait
Dedicated action `myOne`, the single-record sibling of {@see OwnedListTrait}.
It exists for one caller: the state of the "follow" button on an advert
(FollowTrait::isFollowing()
and FollowTrait::initFollower()).
It asks findBy(advert = X, userId = me), which is a getBy, i.e. a collection query with
caller-supplied filters, and allow_if_owner on it is always a deny.
The rules are the same as for myList (see its docblock): no actionMyOne() (so externally
404), the owner comes solely from getJwtPayload(), the caller's filter can only narrow the
result, and without an identity the result is empty with no DB query.
NOTE: the empty result [] equals what getBy returns without a match
(ApiMapper::findBy() maps empty($data) to
null), so an anonymous visitor sees "not following".
Table of Contents
Methods
- internalActionMyOne() : array<string, mixed>
- ownedOneUserField() : string
Methods
internalActionMyOne()
public
internalActionMyOne([array<string|int, Filter|array<string, mixed>> $filters = [] ][, string|array<int, string> $includes = [] ]) : array<string, mixed>
Parameters
- $filters : array<string|int, Filter|array<string, mixed>> = []
-
the caller's filters, which may only narrow the result
- $includes : string|array<int, string> = []
Return values
array<string, mixed> —extractWithReferences payload, an empty array when nothing
matches, or the guard's denial
ownedOneUserField()
protected
ownedOneUserField() : string