public function __invoke($serviceLocator) { $config = $serviceLocator->get('config'); $this->acl = $serviceLocator->get('MultiRoleAclBase\\Service\\MultiRolesAcl'); if (get_class($this->acl) == 'MultiRoleAclBase\\Service\\MultiRolesAcl' || is_subclass_of($this->acl, 'MultiRoleAclBase\\Service\\MultiRolesAcl')) { $this->acl->setAllowAccessWhenResourceUnknown(false); } $this->roleBuilder = $serviceLocator->get('MultiRoleAclBase\\Acl\\Builder\\RoleBuilder'); $this->resourceBuilder = $serviceLocator->get('MultiRoleAclBase\\Acl\\Builder\\ResourceBuilder'); $this->ruleBuilder = $serviceLocator->get('MultiRoleAclBase\\Acl\\Builder\\RuleBuilder'); // Get all Roles from RoleBuilder $roles = $this->roleBuilder->buildRoles($this->acl, $serviceLocator); if (is_array($roles)) { foreach ($roles as $role) { $this->acl->addRole($role); } } // Get all Resources from ResourceBuilder $resources = $this->resourceBuilder->buildResources($this->acl, $serviceLocator); if (is_array($resources)) { foreach ($resources as $resource) { $this->acl->addResource($resource); } } // Build all the rules $this->ruleBuilder->buildRules($this->acl, $serviceLocator); return $this->acl; }