/** * delete a test class or sublcass * * @access public * @author Joel Bout, <*****@*****.**> * @param Class clazz * @return boolean */ public function deleteTestClass(core_kernel_classes_Class $clazz) { $returnValue = (bool) false; if (!is_null($clazz)) { if ($this->isTestClass($clazz) && $clazz->getUri() != $this->testClass->getUri()) { $returnValue = $clazz->delete(); } } return (bool) $returnValue; }
/** * check if the class is a or a subclass of an Item * * @access public * @author Joel Bout, <*****@*****.**> * @param core_kernel_classes_Class clazz * @return boolean */ public function isItemClass(core_kernel_classes_Class $clazz) { $returnValue = (bool) false; if ($this->itemClass->getUri() == $clazz->getUri()) { return true; } foreach ($clazz->getParentClasses(true) as $parent) { if ($parent->getUri() == $this->itemClass->getUri()) { $returnValue = true; break; } } return (bool) $returnValue; }
/** * Found all the properties of the class. * It gets also the parent's properties between * the class and the topclass. * If the topclass is not defined, the GenerisResource class is used. * If there is more than one parent's class, the best path is calculated. * * @access protected * @author Bertrand Chevrier, <*****@*****.**> * @return array */ protected function findProperties() { $returnValue = array(); if (is_null($this->topclass)) { $parents = $this->class->getParentClasses(true); } else { //determine the parent path $parents = array(); $top = false; do { if (!isset($lastLevelParents)) { $parentClasses = $this->class->getParentClasses(false); } else { $parentClasses = array(); foreach ($lastLevelParents as $parent) { $parentClasses = array_merge($parentClasses, $parent->getParentClasses(false)); } } if (count($parentClasses) == 0) { break; } $lastLevelParents = array(); foreach ($parentClasses as $parentClass) { if ($parentClass->getUri() == RDFS_CLASS) { continue; } if ($parentClass->equals($this->topclass)) { $parents[$parentClass->getUri()] = $parentClass; $top = true; break; } $allParentClasses = $parentClass->getParentClasses(true); if (array_key_exists($this->topclass->getUri(), $allParentClasses)) { $parents[$parentClass->getUri()] = $parentClass; } $lastLevelParents[$parentClass->getUri()] = $parentClass; } } while (!$top); } $returnValue = array_merge(array(RDFS_LABEL => new \core_kernel_classes_Property(RDFS_LABEL), RDFS_COMMENT => new \core_kernel_classes_Property(RDFS_COMMENT)), $this->class->getProperties(false)); foreach ($parents as $parent) { $returnValue = array_merge($returnValue, $parent->getProperties(false)); } $this->_properties = $returnValue; return (array) $returnValue; }