Documentation

CheckAccessTrait

Define an implementation of `civi.api4.authorizeRecord` in which access-control decisions are based on a predefined list. For example:

$this->setCheckAccessGrants(['Contact::create' => TRUE]); Contact::create()->setValues(...)->execute();

Note: Any class which uses this should implement the HookInterface so that the hook is picked up.

Table of Contents

Properties

$checkAccessCounts  : array<string|int, mixed>
Number of times hook_checkAccess has fired.
$checkAccessGrants  : array<string|int, mixed>
Specify whether to grant access to an entity-action via hook_checkAccess.

Methods

on_civi_api4_authorizeRecord()  : void
Listen to 'civi.api4.authorizeRecord'. Override decisions with specified grants.
resetCheckAccess()  : mixed
setCheckAccessGrants()  : mixed

Properties

$checkAccessCounts

Number of times hook_checkAccess has fired.

protected array<string|int, mixed> $checkAccessCounts = []

$checkAccessGrants

Specify whether to grant access to an entity-action via hook_checkAccess.

private array<string|int, mixed> $checkAccessGrants = []

Array(string $entityAction => bool $grant). TRUE=>Allow. FALSE=>Deny. Undefined=>No preference.

Methods

setCheckAccessGrants()

protected setCheckAccessGrants(array<string|int, mixed> $list) : mixed
Parameters
$list : array<string|int, mixed>

Ex: ["Event::delete" => TRUE, "Contribution::delete" => FALSE]


        
On this page

Search results