public function moveInstance()
    {
        $response = array();
        if($this->hasRequestParameter('destinationClassUri') && $this->hasRequestParameter('uri')){

            $id = $this->getRequestParameter('uri');

            $this->validateInstanceRoot($id);

            $this->signatureValidator->checkSignature($this->getRequestParameter('signature'), $id);

            $instance = $this->getResource($id);
            $types = $instance->getTypes();
            $clazz = reset($types);
            $destinationUri = tao_helpers_Uri::decode($this->getRequestParameter('destinationClassUri'));

            if(!empty($destinationUri) && $destinationUri != $clazz->getUri()){
                $destinationClass = $this->getClass($destinationUri);

                $confirmed = $this->getRequestParameter('confirmed');
                if(empty($confirmed) || $confirmed == 'false' || $confirmed ===  false){

                    $diff = $this->getClassService()->getPropertyDiff($clazz, $destinationClass);
                    if(count($diff) > 0){
                        return $this->returnJson(array(
                            'status'        => 'diff',
                            'data'          => $diff
                        ));
                    }
                }

                $status = $this->getClassService()->changeClass($instance, $destinationClass);
                $response = array('status'      => $status);
            }
        }
        $this->returnJson($response);
    }
public function moveInstance()
    {
        $response = array();
        if($this->hasRequestParameter('destinationClassUri') && $this->hasRequestParameter('uri')){

            $id = $this->getRequestParameter('uri');

            $this->validateInstanceRoot($id);

            $this->signatureValidator->checkSignature($this->getRequestParameter('signature'), $id);

            $instance = $this->getResource($id);
            $types = $instance->getTypes();
            $clazz = reset($types);
            $destinationUri = tao_helpers_Uri::decode($this->getRequestParameter('destinationClassUri'));

            if(!empty($destinationUri) && $destinationUri != $clazz->getUri()){
                $destinationClass = $this->getClass($destinationUri);

                $confirmed = $this->getRequestParameter('confirmed');
                if(empty($confirmed) || $confirmed == 'false' || $confirmed ===  false){

                    $diff = $this->getClassService()->getPropertyDiff($clazz, $destinationClass);
                    if(count($diff) > 0){
                        return $this->returnJson(array(
                            'status'        => 'diff',
                            'data'          => $diff
                        ));
                    }
                }

                $status = $this->getClassService()->changeClass($instance, $destinationClass);
                $response = array('status'      => $status);
            }
        }
        $this->returnJson($response);
    }
public function moveInstance ( ) { $ response = array ( ) ; if ( $ this -> hasRequestParameter ( 'destinationClassUri' ) && $ this -> hasRequestParameter ( 'uri' ) ) { $ id = $ this -> getRequestParameter ( 'uri' ) ; $ this -> validateInstanceRoot ( $ id ) ; $ this -> signatureValidator -> checkSignature ( $ this -> getRequestParameter ( 'signature' ) , $ id ) ; $ instance = $ this -> getResource ( $ id ) ; $ types = $ instance -> getTypes ( ) ; $ clazz = reset ( $ types ) ; $ destinationUri = tao_helpers_Uri :: decode ( $ this -> getRequestParameter ( 'destinationClassUri' ) ) ; if ( ! empty ( $ destinationUri ) && $ destinationUri != $ clazz -> getUri ( ) ) { $ destinationClass = $ this -> getClass ( $ destinationUri ) ; $ confirmed = $ this -> getRequestParameter ( 'confirmed' ) ; if ( empty ( $ confirmed ) || $ confirmed == 'false' || $ confirmed === false ) { $ diff = $ this -> getClassService ( ) -> getPropertyDiff ( $ clazz , $ destinationClass ) ; if ( count ( $ diff ) > 0 ) { return $ this -> returnJson ( array ( 'status' => 'diff' , 'data' => $ diff ) ) ; } } $ status = $ this -> getClassService ( ) -> changeClass ( $ instance , $ destinationClass ) ; $ response = array ( 'status' => $ status ) ; } } $ this -> returnJson ( $ response ) ; }
Move an instance from a class to another
@return void
@requiresRight uri WRITE
@requiresRight destinationClassUri WRITE
Move an instance from a class to another