Class IdentityDecorator
An decorator implementing the IdentityInterface.
This decorator is intended to wrap the application defined identity object and proxy attributes/methods to and 'mixin' the can() method.
The decorated identity must implement ArrayAccess or be an array.
Property Summary
-
$authorization protected
Authorization\AuthorizationServiceInterface
Authorization Service
-
$identity protected
ArrayAccess|array
Identity data
Method Summary
-
__call() public
Delegate unknown methods to decorated identity.
-
__construct() public
Constructor
-
__get() public
Delegate property access to decorated identity.
-
__isset() public
Delegate property isset to decorated identity.
-
applyScope() public
Apply authorization scope conditions/restrictions.
-
can() public
Check whether the current identity can perform an action.
-
canResult() public
Check whether the current identity can perform an action.
-
getOriginalData() public
Get the decorated identity
-
offsetExists() public
Whether a offset exists
-
offsetGet() public
Offset to retrieve
-
offsetSet() public
Offset to set
-
offsetUnset() public
Offset to unset
Method Detail
__call() ¶ public
__call(string $method, array $args): mixed
Delegate unknown methods to decorated identity.
Parameters
-
string
$method The method being invoked.
-
array
$args The arguments for the method.
Returns
mixed
__construct() ¶ public
__construct(Authorization\AuthorizationServiceInterface $service, ArrayAccess|array $identity)
Constructor
Parameters
-
Authorization\AuthorizationServiceInterface
$service The authorization service.
-
ArrayAccess|array
$identity Identity data
__get() ¶ public
__get(string $property): mixed
Delegate property access to decorated identity.
Parameters
-
string
$property The property to read.
Returns
mixed
__isset() ¶ public
__isset(string $property): bool
Delegate property isset to decorated identity.
Parameters
-
string
$property The property to read.
Returns
bool
applyScope() ¶ public
applyScope(string $action, mixed $resource, mixed ...$optionalArgs): mixed
Apply authorization scope conditions/restrictions.
Parameters
-
string
$action -
mixed
$resource -
mixed
...$optionalArgs
Returns
mixed
can() ¶ public
can(string $action, mixed $resource): bool
Check whether the current identity can perform an action.
Parameters
-
string
$action -
mixed
$resource
Returns
bool
canResult() ¶ public
canResult(string $action, mixed $resource): Authorization\Policy\ResultInterface
Check whether the current identity can perform an action.
Parameters
-
string
$action -
mixed
$resource
Returns
Authorization\Policy\ResultInterface
getOriginalData() ¶ public
getOriginalData(): ArrayAccess|array
Get the decorated identity
If the decorated identity implements getOriginalData()
that method should be invoked to expose the original data.
Returns
ArrayAccess|array
offsetExists() ¶ public
offsetExists(mixed $offset): bool
Whether a offset exists
Parameters
-
mixed
$offset Offset
Returns
bool
Links
offsetGet() ¶ public
offsetGet(mixed $offset): mixed
Offset to retrieve
Parameters
-
mixed
$offset Offset
Returns
mixed
Links
offsetSet() ¶ public
offsetSet(mixed $offset, mixed $value): void
Offset to set
Parameters
-
mixed
$offset The offset to assign the value to.
-
mixed
$value Value
Returns
void
Links
offsetUnset() ¶ public
offsetUnset(mixed $offset): void
Offset to unset
Parameters
-
mixed
$offset Offset
Returns
void