public function cloneInstance(core_kernel_classes_Resource $instance, core_kernel_classes_Class $clazz = null)
    {
        if (is_null($clazz)) {
            $types = $instance->getTypes();
            $clazz = current($types);
        }

        $returnValue = $this->createInstance($clazz);
        if (!is_null($returnValue)) {
            $properties = $clazz->getProperties(true);
            foreach ($properties as $property) {
                $this->cloneInstanceProperty($instance, $returnValue, $property);
            }
            $label = $instance->getLabel();
            $cloneLabel = "$label bis";
            if (preg_match("/bis(\s[0-9]+)?$/", $label)) {
                $cloneNumber = (int)preg_replace("/^(.?)*bis/", "", $label);
                $cloneNumber++;
                $cloneLabel = preg_replace("/bis(\s[0-9]+)?$/", "", $label)."bis $cloneNumber" ;
            }

            $returnValue->setLabel($cloneLabel);
        }

        return $returnValue;
    }
public function cloneInstance(core_kernel_classes_Resource $instance, core_kernel_classes_Class $clazz = null)
    {
        if (is_null($clazz)) {
            $types = $instance->getTypes();
            $clazz = current($types);
        }

        $returnValue = $this->createInstance($clazz);
        if (!is_null($returnValue)) {
            $properties = $clazz->getProperties(true);
            foreach ($properties as $property) {
                $this->cloneInstanceProperty($instance, $returnValue, $property);
            }
            $label = $instance->getLabel();
            $cloneLabel = "$label bis";
            if (preg_match("/bis(\s[0-9]+)?$/", $label)) {
                $cloneNumber = (int)preg_replace("/^(.?)*bis/", "", $label);
                $cloneNumber++;
                $cloneLabel = preg_replace("/bis(\s[0-9]+)?$/", "", $label)."bis $cloneNumber" ;
            }

            $returnValue->setLabel($cloneLabel);
        }

        return $returnValue;
    }
public function cloneInstance ( core_kernel_classes_Resource $ instance , core_kernel_classes_Class $ clazz = null ) { if ( is_null ( $ clazz ) ) { $ types = $ instance -> getTypes ( ) ; $ clazz = current ( $ types ) ; } $ returnValue = $ this -> createInstance ( $ clazz ) ; if ( ! is_null ( $ returnValue ) ) { $ properties = $ clazz -> getProperties ( true ) ; foreach ( $ properties as $ property ) { $ this -> cloneInstanceProperty ( $ instance , $ returnValue , $ property ) ; } $ label = $ instance -> getLabel ( ) ; $ cloneLabel = "$label bis" ; if ( preg_match ( "/bis(\s[0-9]+)?$/" , $ label ) ) { $ cloneNumber = ( int ) preg_replace ( "/^(.?)*bis/" , "" , $ label ) ; $ cloneNumber ++ ; $ cloneLabel = preg_replace ( "/bis(\s[0-9]+)?$/" , "" , $ label ) . "bis $cloneNumber" ; } $ returnValue -> setLabel ( $ cloneLabel ) ; } return $ returnValue ; }
duplicate a resource

@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param  core_kernel_classes_Resource $instance
@param  core_kernel_classes_Class $clazz
@return core_kernel_classes_Resource
@throws \League\Flysystem\FileExistsException
@throws \common_Exception
@throws \common_exception_Error
duplicate a resource