PHP Class Jarves\ACLRequest

$acl->check($request): boolean
Show file Open project: jarves/jarves Class Usage Examples

Protected Properties

Property Type Description
$asParent boolean Defines whether this request should be checked as a parent object. This means, it excludes all rules with sub=0 (rules that do not apply to sub-items/children)
$field string | null | array Example: 'title' or ['language' => 'en']
$mode integer ACL::MODE_ALL, ACL::MODE_LISTING, ACL::MODE_VIEW, ACL::MODE_ADD, ACL::MODE_UPDATE, ACL::MODE_DELETE
$objectKey string Example: jarves/node
$primaryKey array | string | null If not defined, rules that have a constraint to a exactly object item are ignored. This includes: Rules that are applied to parent objects and have sub=true and exact rules that are applied to a particular object item. Actually only ACL::CONSTRAINT_ALL are checked then, usually needed for mode==ACL::LISTING String representation as seen in Jarves\Objects::normalizePkString also allowed and will be converted to a real primaryKey array when used.
$primaryObjectItem null | array When a primaryKey is given and we have rules based on fields of a object item, the ACL system needs to fetch this item based on $primaryKey. To speed things up and to check against not yet created objects (like during a 'add'-check), you should pass the actual objectItem to this request.
$rootHasAccess boolean For nested set, the ACL system iterates through all parents. If no rule applies or all rules are from access=inherited, then this option defines whether ACL::check() returns true or false.
$targetId null | integer If not defined current user id from current session is used.
$targetType null ACL::TARGET_TYPE_USER, ACL::TARGET_TYPE_GROUP

Public Methods

Method Description
__construct ( string $objectKey, string | array | null $primaryKey = null )
create ( string $objectKey, string | array | null $primaryKey = null ) : static
getField ( ) : array | null | string
getMode ( ) : integer
getObjectKey ( ) : string
getPrimaryKey ( ) : array | null
getPrimaryObjectItem ( ) : array | string | null
getTargetId ( ) : integer | null
getTargetType ( ) : null
isAsParent ( ) : boolean
isRootHasAccess ( ) : boolean
onlyAddMode ( )
onlyDeleteMode ( )
onlyListingMode ( )
onlyUpdateMode ( )
onlyViewMode ( )
setAsParent ( boolean $asParent )
setField ( array | null | string $field )
setMode ( integer $mode )
setObjectKey ( string $objectKey )
setPrimaryKey ( string | array | null $primaryKey )
setPrimaryObjectItem ( array $primaryObjectItem = null )
setRootHasAccess ( boolean $rootHasAccess )
setTargetId ( integer | null $targetId )
setTargetType ( null $targetType )
targetGroup ( integer $groupId ) Sets targetId= $groupId and targetType = ACL::TARGET_TYPE_GROUP
targetUser ( integer $userId ) Sets targetId= $userId and targetType = ACL::TARGET_TYPE_USER

Method Details

__construct() public method

public __construct ( string $objectKey, string | array | null $primaryKey = null )
$objectKey string
$primaryKey string | array | null see ACLRequest::$primaryKey

create() public static method

public static create ( string $objectKey, string | array | null $primaryKey = null ) : static
$objectKey string
$primaryKey string | array | null see ACLRequest::$primaryKey
return static

getField() public method

public getField ( ) : array | null | string
return array | null | string

getMode() public method

public getMode ( ) : integer
return integer

getObjectKey() public method

public getObjectKey ( ) : string
return string

getPrimaryKey() public method

public getPrimaryKey ( ) : array | null
return array | null

getPrimaryObjectItem() public method

public getPrimaryObjectItem ( ) : array | string | null
return array | string | null

getTargetId() public method

public getTargetId ( ) : integer | null
return integer | null

getTargetType() public method

public getTargetType ( ) : null
return null

isAsParent() public method

public isAsParent ( ) : boolean
return boolean

isRootHasAccess() public method

public isRootHasAccess ( ) : boolean
return boolean

onlyAddMode() public method

public onlyAddMode ( )

onlyDeleteMode() public method

public onlyDeleteMode ( )

onlyListingMode() public method

public onlyListingMode ( )

onlyUpdateMode() public method

public onlyUpdateMode ( )

onlyViewMode() public method

public onlyViewMode ( )

setAsParent() public method

public setAsParent ( boolean $asParent )
$asParent boolean

setField() public method

public setField ( array | null | string $field )
$field array | null | string

setMode() public method

public setMode ( integer $mode )
$mode integer ACL::MODE_ALL, ACL::MODE_LISTING, ACL::MODE_VIEW, ACL::MODE_ADD, ACL::MODE_UPDATE, ACL::MODE_DELETE

setObjectKey() public method

public setObjectKey ( string $objectKey )
$objectKey string

setPrimaryKey() public method

public setPrimaryKey ( string | array | null $primaryKey )
$primaryKey string | array | null see ACLRequest::$primaryKey

setPrimaryObjectItem() public method

public setPrimaryObjectItem ( array $primaryObjectItem = null )
$primaryObjectItem array

setRootHasAccess() public method

public setRootHasAccess ( boolean $rootHasAccess )
$rootHasAccess boolean

setTargetId() public method

public setTargetId ( integer | null $targetId )
$targetId integer | null

setTargetType() public method

public setTargetType ( null $targetType )
$targetType null

targetGroup() public method

Sets targetId= $groupId and targetType = ACL::TARGET_TYPE_GROUP
public targetGroup ( integer $groupId )
$groupId integer

targetUser() public method

Sets targetId= $userId and targetType = ACL::TARGET_TYPE_USER
public targetUser ( integer $userId )
$userId integer

Property Details

$asParent protected property

Defines whether this request should be checked as a parent object. This means, it excludes all rules with sub=0 (rules that do not apply to sub-items/children)
protected bool $asParent
return boolean

$field protected property

Example: 'title' or ['language' => 'en']
protected string|null|array $field
return string | null | array

$mode protected property

ACL::MODE_ALL, ACL::MODE_LISTING, ACL::MODE_VIEW, ACL::MODE_ADD, ACL::MODE_UPDATE, ACL::MODE_DELETE
protected int $mode
return integer

$objectKey protected property

Example: jarves/node
protected string $objectKey
return string

$primaryKey protected property

If not defined, rules that have a constraint to a exactly object item are ignored. This includes: Rules that are applied to parent objects and have sub=true and exact rules that are applied to a particular object item. Actually only ACL::CONSTRAINT_ALL are checked then, usually needed for mode==ACL::LISTING String representation as seen in Jarves\Objects::normalizePkString also allowed and will be converted to a real primaryKey array when used.
protected array|string|null $primaryKey
return array | string | null

$primaryObjectItem protected property

When a primaryKey is given and we have rules based on fields of a object item, the ACL system needs to fetch this item based on $primaryKey. To speed things up and to check against not yet created objects (like during a 'add'-check), you should pass the actual objectItem to this request.
protected null|array $primaryObjectItem
return null | array

$rootHasAccess protected property

For nested set, the ACL system iterates through all parents. If no rule applies or all rules are from access=inherited, then this option defines whether ACL::check() returns true or false.
protected bool $rootHasAccess
return boolean

$targetId protected property

If not defined current user id from current session is used.
protected null|int $targetId
return null | integer

$targetType protected property

ACL::TARGET_TYPE_USER, ACL::TARGET_TYPE_GROUP
protected null $targetType
return null