getResource($content['id']); $topLevelClass = $this->getClass(TaoOntology::CLASS_URI_OBJECT); $permissionHelper = $this->getPermissionHelper(); foreach ($resource->getTypes() as $type) { $accessibleResources = $permissionHelper->filterByPermission( [$type->getUri()], PermissionInterface::RIGHT_READ ); if (empty($accessibleResources)) { return false; } $class = $this->getClass($type->getUri()); if (!$this->hasReadPermissionForClass($class, $permissionHelper, $topLevelClass)) { return false; } } return true; } private function hasReadPermissionForClass( core_kernel_classes_Class $class, PermissionHelper $permissionHelper, core_kernel_classes_Class $topLevelClass ): bool { $parentClasses = $class->getParentClasses(true); foreach ($parentClasses as $parentClass) { $accessibleResource = $permissionHelper ->filterByPermission( [$parentClass->getUri()], PermissionInterface::RIGHT_READ ); if (empty($accessibleResource)) { return false; } if ($parentClass->getUri() === $topLevelClass->getUri()) { return true; } } return true; } private function getPermissionHelper(): PermissionHelper { return $this->getServiceLocator()->get(PermissionHelper::class); } }