public function cloneClazz(
        core_kernel_classes_Class $sourceClazz,
        core_kernel_classes_Class $newParentClazz = null,
        core_kernel_classes_Class $topLevelClazz = null
    ) {
        $returnValue = null;

        if (!is_null($sourceClazz) && !is_null($newParentClazz)) {
            if ((is_null($topLevelClazz))) {
                $properties = $sourceClazz->getProperties(false);
            } else {
                $properties = $this->getClazzProperties($sourceClazz, $topLevelClazz);
            }

            //check for duplicated properties
            $newParentProperties = $newParentClazz->getProperties(true);
            foreach ($properties as $index => $property) {
                foreach ($newParentProperties as $newParentProperty) {
                    if ($property->getUri() == $newParentProperty->getUri()) {
                        unset($properties[$index]);
                        break;
                    }
                }
            }

            //create a new class
            $returnValue = $this->createSubClass($newParentClazz, $sourceClazz->getLabel());

            //assign the properties of the source class
            foreach ($properties as $property) {
                $property->setDomain($returnValue);
            }
        }
        return $returnValue;
    }
public function cloneClazz(
        core_kernel_classes_Class $sourceClazz,
        core_kernel_classes_Class $newParentClazz = null,
        core_kernel_classes_Class $topLevelClazz = null
    ) {
        $returnValue = null;

        if (!is_null($sourceClazz) && !is_null($newParentClazz)) {
            if ((is_null($topLevelClazz))) {
                $properties = $sourceClazz->getProperties(false);
            } else {
                $properties = $this->getClazzProperties($sourceClazz, $topLevelClazz);
            }

            //check for duplicated properties
            $newParentProperties = $newParentClazz->getProperties(true);
            foreach ($properties as $index => $property) {
                foreach ($newParentProperties as $newParentProperty) {
                    if ($property->getUri() == $newParentProperty->getUri()) {
                        unset($properties[$index]);
                        break;
                    }
                }
            }

            //create a new class
            $returnValue = $this->createSubClass($newParentClazz, $sourceClazz->getLabel());

            //assign the properties of the source class
            foreach ($properties as $property) {
                $property->setDomain($returnValue);
            }
        }
        return $returnValue;
    }
public function cloneClazz ( core_kernel_classes_Class $ sourceClazz , core_kernel_classes_Class $ newParentClazz = null , core_kernel_classes_Class $ topLevelClazz = null ) { $ returnValue = null ; if ( ! is_null ( $ sourceClazz ) && ! is_null ( $ newParentClazz ) ) { if ( ( is_null ( $ topLevelClazz ) ) ) { $ properties = $ sourceClazz -> getProperties ( false ) ; } else { $ properties = $ this -> getClazzProperties ( $ sourceClazz , $ topLevelClazz ) ; } //check for duplicated properties $ newParentProperties = $ newParentClazz -> getProperties ( true ) ; foreach ( $ properties as $ index => $ property ) { foreach ( $ newParentProperties as $ newParentProperty ) { if ( $ property -> getUri ( ) == $ newParentProperty -> getUri ( ) ) { unset ( $ properties [ $ index ] ) ; break ; } } } //create a new class $ returnValue = $ this -> createSubClass ( $ newParentClazz , $ sourceClazz -> getLabel ( ) ) ; //assign the properties of the source class foreach ( $ properties as $ property ) { $ property -> setDomain ( $ returnValue ) ; } } return $ returnValue ; }
Clone a Class and move it under the newParentClazz

@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param  core_kernel_classes_Class $sourceClazz
@param  core_kernel_classes_Class $newParentClazz
@param  core_kernel_classes_Class $topLevelClazz
@return core_kernel_classes_Class|null
@throws \common_exception_Error
Clone a Class and move it under the newParentClazz