/** * buildParent * * @param AclResource $resource * * @return AclResource * @throws RcmUserException */ public function buildParent(AclResource $resource) { $parentResourceId = $resource->getParentResourceId(); // root parent must be null if ($resource->getResourceId() == $this->rootResource->getResourceId()) { $resource->setParentResourceId(null); return $resource; } if (empty($parentResourceId)) { $resource->setParentResourceId($this->rootResource->getResourceId()); } return $resource; }
/** * buildResources - build static resources * * @return void */ protected function buildResources() { $privileges = ['read', 'update', 'create', 'delete']; $userPrivileges = ['read', 'update', 'create', 'delete', 'update_credentials']; /* parent resource */ $resource = new AclResource(self::RESOURCE_ID_ROOT); $resource->setName('RCM User'); $resource->setDescription('All RCM user access.'); $resource->setPrivileges($privileges); $this->resources[self::RESOURCE_ID_ROOT] = $resource; /* user edit */ $resource = new AclResource(self::RESOURCE_ID_USER, self::RESOURCE_ID_ROOT, $userPrivileges); $resource->setName('User Administration'); $resource->setDescription('Allows the editing of user data.'); $this->resources[self::RESOURCE_ID_USER] = $resource; /* access and roles */ $resource = new AclResource(self::RESOURCE_ID_ACL, self::RESOURCE_ID_ROOT, $privileges); $resource->setName('Role and Access Administration'); $resource->setDescription('Allows the editing of user access and role data.'); $resource->setParentResourceId(self::RESOURCE_ID_ROOT); $this->resources[self::RESOURCE_ID_ACL] = $resource; }