CoolCMS API

ConditionalRoleSupport
in package

FinalYes

Tells whether an Api presenter can evaluate a conditional role for a given key.

A conditional grant (conditional = 1) allows nothing by itself; the presenter's own check decides. Without such a check the grant is a fail-closed denial, i.e. dead and misleading. Used by the permission matrix admin (the checkbox is disabled for unsupported rows) and by the server on save (UserRolePrivilegeMatrixManager), which rejects a new dead grant.

Detected by reflection, so it proves that a check exists, not that it is correct:

  • owner: the presenter overrides verifyOwnership() (its own or from OwnershipCheckTrait; traits are copied into the consuming class, so the declaring class stops being BasePresenter), or its entity implements OwnerAwareInterface.
  • receiver: the presenter entity implements ReceiverAwareInterface, or the presenter overrides isReceiver().

The presenter entity is the ENTITY_CLASS constant, otherwise the Api entity of the same name in the presenter module; see self::resolveEntityClass(). An unknown conditional role cannot be judged and is treated as supported.

IMPORTANT: the caches are instance properties, not static; in a long-running worker a static cache would survive a presenter fix.

Table of Contents

Constants

ROLE_OWNER  : mixed = 'owner'
ROLE_RECEIVER  : mixed = 'receiver'

Properties

$ownerCache  : array<string, bool>
$receiverCache  : array<string, bool>

Methods

hasOwnerSupport()  : bool
hasReceiverSupport()  : bool
supports()  : bool
Returns whether a grant of this conditional role (`owner`/`receiver`) has any effect for the `:Api:Module:Presenter:action` key.
reflectOwnerSupport()  : bool
reflectReceiverSupport()  : bool
resolveEntityClass()  : class-string|null
Returns the entity the presenter works on: the `ENTITY_CLASS` constant, otherwise the convention `App\UI\Api\<Module>\Models\Entities\<Presenter>`, or `null` when neither exists.
resolvePresenterClass()  : string|null
Maps `:Api:Eshop:Order:transition` to its presenter class; keys outside `:Api:` return `null`.

Constants

Properties

$ownerCache

private array<string, bool> $ownerCache = []

presenter class => has its own verifyOwnership()

$receiverCache

private array<string, bool> $receiverCache = []

presenter class => supports the receiver check

Methods

hasOwnerSupport()

public hasOwnerSupport(string $key) : bool
Parameters
$key : string
Return values
bool

hasReceiverSupport()

public hasReceiverSupport(string $key) : bool
Parameters
$key : string
Return values
bool

supports()

Returns whether a grant of this conditional role (`owner`/`receiver`) has any effect for the `:Api:Module:Presenter:action` key.

public supports(string $roleCode, string $key) : bool
Parameters
$roleCode : string
$key : string
Return values
bool

reflectOwnerSupport()

private reflectOwnerSupport(string $presenterClass) : bool
Parameters
$presenterClass : string
Return values
bool

reflectReceiverSupport()

private reflectReceiverSupport(string $presenterClass) : bool
Parameters
$presenterClass : string
Return values
bool

resolveEntityClass()

Returns the entity the presenter works on: the `ENTITY_CLASS` constant, otherwise the convention `App\UI\Api\<Module>\Models\Entities\<Presenter>`, or `null` when neither exists.

private resolveEntityClass(class-string $presenterClass) : class-string|null

A manager's entity is known only to an instance at runtime, hence the convention.

Parameters
$presenterClass : class-string
Return values
class-string|null

resolvePresenterClass()

Maps `:Api:Eshop:Order:transition` to its presenter class; keys outside `:Api:` return `null`.

private resolvePresenterClass(string $key) : string|null
Parameters
$key : string
Return values
string|null
On this page

Search results