\AclUser\Permissions\AclAccessControlList

This class initialises and extends AclUser\Permissions\Acl and defines which roles are allowed to access which resources with what privileges

Extends Zend\Acl

Summary

Methods
Properties
Constants
getPresentUser()
getPresentUserId()
getPresentUserEmailAddress()
onDispatch()
disallowedRouteRedirect()
userIsAllowed()
__construct()
No public properties found
No constants found
defineRoles()
defineResources()
joinAclToNavigation()
checkAddParentRole()
addPresentUserAgrigateRole()
setAgragateRolesByUserId()
addMemRole()
assignPriveleges()
$roleMemory
$allRoles
$config
$authService
$userManager
N/A
checkThatRouteExists()
isParticularRoute()
No private properties found
N/A

Properties

$roleMemory

$roleMemory : array

An array that stores the role name under the role's id as key

Type

array

$allRoles

$allRoles : array

Array (strings) of all roles that exist in database

Type

array

$config

$config : array

Configuration array

Type

array

$authService

$authService : \AclUser\Permissions\Acl\Zend\Authentication\AuthenticationService

Authentication and Identity management helper

Type

\AclUser\Permissions\Acl\Zend\Authentication\AuthenticationService

$userManager

$userManager : \AclUser\Permissions\Acl\AclUser\Service\UserManager

UserManager that handles logic for a registered User

Type

\AclUser\Permissions\Acl\AclUser\Service\UserManager

Methods

getPresentUser()

getPresentUser() : null|\AclUser\Permissions\Acl\User

Get the User entity object that represents the present (logged in) user

Returns

null|\AclUser\Permissions\Acl\User —

the logged in user

getPresentUserId()

getPresentUserId() : integer|null

Get the user id (auth service identity) the present (logged in) user

Returns

integer|null —

the present user id

getPresentUserEmailAddress()

getPresentUserEmailAddress() : string

Get the logged in user's e-mail address

Returns

string —

the logged in user's email address or "Identity" if user is not found

onDispatch()

onDispatch(\Zend\Mvc\MvcEvent  $event) : null

Based on ListenerAggregateInterface this method is called when application dispatches

Parameters

\Zend\Mvc\MvcEvent $event

Returns

null

disallowedRouteRedirect()

disallowedRouteRedirect(\Zend\Mvc\MvcEvent  $event, \Zend\Router\Http\RouteMatch  $routeMatch) : \AclUser\Permissions\Acl\type

Handle request if user is not allowed the access the the requested resource and privilege

Parameters

\Zend\Mvc\MvcEvent $event
\Zend\Router\Http\RouteMatch $routeMatch

Returns

\AclUser\Permissions\Acl\type

userIsAllowed()

userIsAllowed(string  $resource, string  $privilege) : boolean

Check whether current user is allowed to access this resource and privilege

Parameters

string $resource
string $privilege

Returns

boolean —

whether user is permitted to access this route

__construct()

__construct(array  $resources, \Zend\Authentication\AuthenticationService  $authService, \AclUser\Service\UserManager  $userManager, array  $config) 

Instantiate class

Parameters

array $resources

list of resources

\Zend\Authentication\AuthenticationService $authService
\AclUser\Service\UserManager $userManager
array $config

defineRoles()

defineRoles() 

add all roles used by the application to the access control list parent object

defineResources()

defineResources(array  $resources) 

add all resources used by the application to the access control list parent object

Parameters

array $resources

array of (string) resources

joinAclToNavigation()

joinAclToNavigation() 

Set user role and this ACL for navigation

checkAddParentRole()

checkAddParentRole(\AclUser\Permissions\Acl\AclUser\Entity\Role  $role) 

Check whether role and parent role has been added to this ACL and store role so that it is not added a second time

Parameters

\AclUser\Permissions\Acl\AclUser\Entity\Role $role

addPresentUserAgrigateRole()

addPresentUserAgrigateRole() 

add the user role 'present_unique_user' that is used for all users And add the present users roles array as parent of this role

setAgragateRolesByUserId()

setAgragateRolesByUserId(\AclUser\Permissions\Acl\Entity\User  $user) 

Concatenate all users roles and add present_unique_user as child of all those roles

Parameters

\AclUser\Permissions\Acl\Entity\User $user

addMemRole()

addMemRole(\AclUser\Permissions\Acl\AclUser\Entity\Role  $role, string|null  $parentId = NULL) 

Persist roles for later use within this class

Parameters

\AclUser\Permissions\Acl\AclUser\Entity\Role $role
string|null $parentId

assignPriveleges()

assignPriveleges() 

Update this method in to assign privileges for roles to access resources.

checkThatRouteExists()

checkThatRouteExists(\Zend\Router\Http\RouteMatch  $routeMatch) 

Check whether this route corresponds to a real controller and action

Parameters

\Zend\Router\Http\RouteMatch $routeMatch

isParticularRoute()

isParticularRoute(\Zend\Router\Http\RouteMatch  $routeMatch, string  $controller, string  $action) : boolean

Check whether this is particular route as defined by the controller and the action

Parameters

\Zend\Router\Http\RouteMatch $routeMatch
string $controller
string $action

Returns

boolean