delete(); } /** * Delete a subclass * * @access public * @param \core_kernel_classes_Class $clazz * @return boolean * @throws \common_exception_Error */ public function deleteClass(\core_kernel_classes_Class $clazz) { $returnValue = (bool) false; if ($clazz->isSubClassOf($this->getRootClass()) && ! $clazz->equals($this->getRootClass())) { $returnValue = true; $instances = $clazz->getInstances(); foreach ($instances as $instance) { $this->deleteResource($instance); } $subclasses = $clazz->getSubClasses(false); foreach ($subclasses as $subclass) { $returnValue = $returnValue && $this->deleteClass($subclass); } foreach ($clazz->getProperties() as $classProperty) { $returnValue = $returnValue && $this->deleteClassProperty($classProperty); } $returnValue = $returnValue && $clazz->delete(); } else { \common_Logger::w('Tried to delete class ' . $clazz->getUri() . ' as if it were a subclass of ' . $this->getRootClass()->getUri()); } return (bool) $returnValue; } /** * remove a class property * * @param \core_kernel_classes_Property $property * @return bool * @throws \common_exception_Error */ public function deleteClassProperty(\core_kernel_classes_Property $property) { $indexes = $property->getPropertyValues(new \core_kernel_classes_Property(OntologyIndex::PROPERTY_INDEX)); //delete property and the existing values of this property if ($returnValue = $property->delete(true)) { //delete index linked to the property foreach ($indexes as $indexUri) { $index = new \core_kernel_classes_Resource($indexUri); $returnValue = $this->deletePropertyIndex($index); } } return $returnValue; } /** * remove an index property * @param \core_kernel_classes_Resource $index * @return bool */ public function deletePropertyIndex(\core_kernel_classes_Resource $index) { return $index->delete(true); } /** * @return ServiceManager */ public function getServiceManager() { return ServiceManager::getServiceManager(); } }