dataAccessControl = $dataAccessControl; return $this; } public function hasWriteAccess(string $resourceId, User $user = null): bool { return $this->hasAccess($resourceId, self::PERMISSION_WRITE, $user); } public function hasReadAccess(string $resourceId, User $user = null): bool { return $this->hasAccess($resourceId, self::PERMISSION_READ, $user); } public function hasGrantAccess(string $resourceId, User $user = null): bool { return $this->hasAccess($resourceId, self::PERMISSION_GRANT, $user); } private function hasAccess(string $resourceId, string $access, User $user = null): bool { return $this->getAccessControl()->hasPrivileges( $user ?? $this->getUser(), [ $resourceId => $access ] ); } private function getUser(): User { return common_session_SessionManager::getSession()->getUser(); } private function getAccessControl(): AccessControl { if (!$this->dataAccessControl) { $this->dataAccessControl = new DataAccessControl(); } return $this->dataAccessControl; } }