CoolCMS API

FieldAccess
in package

FinalYes

Field tier: who receives the field (`read`), who may fill it in when creating (`insert`) and who may change it on an existing record (`update`, including `updateColumn(s)`).

A field without the attribute behaves as all/all/all. A stripped field keeps its stored value: the DB value on update, the constructor default on insert. A stripped insert field is therefore safe only when the manager fills the server-computed value itself.

IMPORTANT: all three axes are required, with no defaults. Otherwise a forgotten axis cannot be told from an intended one and stays silently open. NOTE: read is enforced on both paths. On the write axes only Audience::None applies everywhere; other audiences are enforced on the external save only, and Audience::Owner is treated as Audience::Privileged there. updateCheck (contract of ConditionallyUpdatable) is reserved for owner checks and not evaluated yet.

Usage:

#[FieldAccess(read: Audience::Privileged, insert: Audience::Privileged, update: Audience::None)]
protected ?string $settings = null;
Tags
see
Audience

vocabulary of audiences (maps to cms_system_user_roles columns)

FieldAccessCoverageTest

fail-closed safeguard over field names

Attributes
#[Attribute]
\Attribute::TARGET_PROPERTY

Table of Contents

Properties

$insert  : Audience
$read  : Audience
$update  : Audience
$updateCheck  : string|null

Methods

__construct()  : mixed

Properties

$updateCheck read-only

public string|null $updateCheck = null

Methods

__construct()

public __construct(Audience $read, Audience $insert, Audience $update[, string|null $updateCheck = null ]) : mixed
Parameters
$read : Audience

who receives the field from get/getBy/getAll and includes

$insert : Audience

who may fill it in when creating (payload without id)

$update : Audience

who may change it on an existing record (payload with id and updateColumn(s))

$updateCheck : string|null = null

presenter method name for Audience::Owner when the owner is not on this record (reserved, not evaluated yet)

On this page

Search results