CoolCMS API

OwnedListTrait

Dedicated collection action `myList` with a server-injected owner filter.

This is the final shape for owner-scoped collections, not an interim step: allow_if_owner on a collection is always a deny (a collection has no owner), so ownership cannot be expressed as a grant and is expressed as a filter instead. It follows the pattern of the dedicated actions :Api:Eshop:Order:myOrders and :Api:System:Payment:payPage.

The grant rests on four properties:

  1. There is no actionMyList() and it must not get one. Without an action*() Nette rejects an external request with 404 before anything loads (even with an admin token), so a registrated grant on myList opens no external HTTP. Guarded by Tests\Unit\Security\FrontApiSurfacePolicyTest::testInternalOnlyKeysHaveNoActionCounterpart().
  2. The server sets the owner, solely from getJwtPayload()->getUserId(). Caller parameters never decide identity; a userId taken from the request would be the caller's claim instead of an identity.
  3. The caller's filters can only narrow the result. The server EqualFilter is added to them and all filters combine through andWhere() (EqualFilter::apply()), so a caller sending userId = 999 gets the intersection with their own userId, i.e. nothing.
  4. Without an identity the result is empty, not an exception, and it is returned without a single DB query (fail-closed). Callers are front-end lists (/hlidaci-pes-prehled, the Blog paywall) where "nothing to show" is the correct degradation and an exception would be a 500.

Not covered here: collections scoped to a single advert instead of "my records" (the Responses / Statistics tabs on the advert edit page, reached by an anonymous user via a password); those belong to AdvertScopedListTrait.

Tags
see
GetAllTrait

getAll stays admin-only and unchanged

Table of Contents

Methods

internalActionMyList()  : array<string, mixed>
ownedListExtraFilters()  : array<int, BaseFilter>
Returns additional server filters added to every list next to the owner filter; the caller cannot omit them.
ownedListUserField()  : string
Returns the entity field that carries the owner.

Methods

internalActionMyList()

public internalActionMyList([array<string|int, Filter|array<string, mixed>> $filters = [] ][, array<string, mixed>|null $orderBys = null ][, int|null $offset = null ][, int|null $limit = null ][, array<int, string>|null $columns = null ][, bool $computeTotalCount = false ][, 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

$orderBys : array<string, mixed>|null = null
$offset : int|null = null
$limit : int|null = null
$columns : array<int, string>|null = null
$computeTotalCount : bool = false
$includes : string|array<int, string> = []
Return values
array<string, mixed> —

extractAll payload (items/totalCount/_references), or the guard's denial

ownedListExtraFilters()

Returns additional server filters added to every list next to the owner filter; the caller cannot omit them.

protected ownedListExtraFilters() : array<int, BaseFilter>

None by default; private messages use it to hide rows of participants removed from the thread.

Return values
array<int, BaseFilter>
On this page

Search results