CoolCMS API

OwnerAwareInterface

Entity that knows who created it (the owner is the author or sender of the record); the named entry point to the generic base of the conditional RBAC role `owner`.

The default owner check (OwnershipCheckTrait::isOwner() internally, ApiPermissionGuardTrait::isOwner()) lets the caller in when the logged-in user id equals self::getOwnerUserId(). Entity columns are not renamed (userId, insertUserId, association user): the method name is uniform, the field is not; the method only returns the value of an existing getter. Filters, OwnedListTrait and getExternalOwnerData() keep working with the field name.

IMPORTANT: the owner is not the receiver (see ReceiverAwareInterface), the subject (whom the record is about) or the actor (who performed the action); implement this only on entities where a user created the record as author or sender, otherwise the wrong person passes the owner check. null means the owner is unknown or anonymous, and the check then returns false. The method must not trigger lazy loading or a database query.

Table of Contents

Methods

getOwnerUserId()  : int|null
Returns the id of the user who created the record; `null` for an unknown or anonymous owner.

Methods

getOwnerUserId()

Returns the id of the user who created the record; `null` for an unknown or anonymous owner.

public getOwnerUserId() : int|null
Return values
int|null
On this page

Search results