public function bind($data)
    {
        $returnValue = null;

        try {
	        $instance = $this->getTargetInstance();
			$eventManager = \oat\oatbox\service\ServiceManager::getServiceManager()->get(\oat\oatbox\event\EventManager::CONFIG_ID);
	        foreach($data as $propertyUri => $propertyValue){

                if($propertyUri == OntologyRdf::RDF_TYPE){
                    foreach($instance->getTypes() as $type){
                        $instance->removeType($type);
                    }
                    if(!is_array($propertyValue)){
                        $types = array($propertyValue) ;
                    }
                    foreach($types as $type){
                        $instance->setType(new core_kernel_classes_Class($type));
                    }
                    continue;
                }

                $prop = new core_kernel_classes_Property( $propertyUri );
                $values = $instance->getPropertyValuesCollection($prop);
                if($values->count() > 0){
                    if(is_array($propertyValue)){
                        $instance->removePropertyValues($prop);
                        foreach($propertyValue as $aPropertyValue){
                            $instance->setPropertyValue(
                                $prop,
                                $aPropertyValue
                            );
                        }

                    }
                    else if (is_string($propertyValue)){
                        $instance->editPropertyValues(
                            $prop,
                            $propertyValue
                        );
                        if(strlen(trim($propertyValue))==0){
                            //if the property value is an empty space(the default value in a select input field), delete the corresponding triplet (and not all property values)
                            $instance->removePropertyValues($prop, array('pattern' => ''));
                        }
                    }
                }
                else{

                    if(is_array($propertyValue)){

                        foreach($propertyValue as $aPropertyValue){
                            $instance->setPropertyValue(
                                $prop,
                                $aPropertyValue
                            );
                        }
                    }
                    else if (is_string($propertyValue) && strlen(trim($propertyValue)) !== 0 ){
                        $instance->setPropertyValue(
                            $prop,
                            $propertyValue
                        );
                    }
                }
                $eventManager->trigger(new \oat\tao\model\event\MetadataModified($instance, $propertyUri, $propertyValue));
	        }
	        
	        $returnValue = $instance;
        }
        catch (common_Exception $e){
        	$msg = "An error occured while binding property values to instance '': " . $e->getMessage();
        	$instanceUri = $instance->getUri();
        	throw new tao_models_classes_dataBinding_GenerisInstanceDataBindingException($msg);
        }
        

        return $returnValue;
    }
public function bind($data)
    {
        $returnValue = null;

        try {
	        $instance = $this->getTargetInstance();
			$eventManager = \oat\oatbox\service\ServiceManager::getServiceManager()->get(\oat\oatbox\event\EventManager::CONFIG_ID);
	        foreach($data as $propertyUri => $propertyValue){

                if($propertyUri == OntologyRdf::RDF_TYPE){
                    foreach($instance->getTypes() as $type){
                        $instance->removeType($type);
                    }
                    if(!is_array($propertyValue)){
                        $types = array($propertyValue) ;
                    }
                    foreach($types as $type){
                        $instance->setType(new core_kernel_classes_Class($type));
                    }
                    continue;
                }

                $prop = new core_kernel_classes_Property( $propertyUri );
                $values = $instance->getPropertyValuesCollection($prop);
                if($values->count() > 0){
                    if(is_array($propertyValue)){
                        $instance->removePropertyValues($prop);
                        foreach($propertyValue as $aPropertyValue){
                            $instance->setPropertyValue(
                                $prop,
                                $aPropertyValue
                            );
                        }

                    }
                    else if (is_string($propertyValue)){
                        $instance->editPropertyValues(
                            $prop,
                            $propertyValue
                        );
                        if(strlen(trim($propertyValue))==0){
                            //if the property value is an empty space(the default value in a select input field), delete the corresponding triplet (and not all property values)
                            $instance->removePropertyValues($prop, array('pattern' => ''));
                        }
                    }
                }
                else{

                    if(is_array($propertyValue)){

                        foreach($propertyValue as $aPropertyValue){
                            $instance->setPropertyValue(
                                $prop,
                                $aPropertyValue
                            );
                        }
                    }
                    else if (is_string($propertyValue) && strlen(trim($propertyValue)) !== 0 ){
                        $instance->setPropertyValue(
                            $prop,
                            $propertyValue
                        );
                    }
                }
                $eventManager->trigger(new \oat\tao\model\event\MetadataModified($instance, $propertyUri, $propertyValue));
	        }
	        
	        $returnValue = $instance;
        }
        catch (common_Exception $e){
        	$msg = "An error occured while binding property values to instance '': " . $e->getMessage();
        	$instanceUri = $instance->getUri();
        	throw new tao_models_classes_dataBinding_GenerisInstanceDataBindingException($msg);
        }
        

        return $returnValue;
    }
public function bind ( $ data ) { $ returnValue = null ; try { $ instance = $ this -> getTargetInstance ( ) ; $ eventManager = \ oat \ oatbox \ service \ ServiceManager :: getServiceManager ( ) -> get ( \ oat \ oatbox \ event \ EventManager :: CONFIG_ID ) ; foreach ( $ data as $ propertyUri => $ propertyValue ) { if ( $ propertyUri == OntologyRdf :: RDF_TYPE ) { foreach ( $ instance -> getTypes ( ) as $ type ) { $ instance -> removeType ( $ type ) ; } if ( ! is_array ( $ propertyValue ) ) { $ types = array ( $ propertyValue ) ; } foreach ( $ types as $ type ) { $ instance -> setType ( new core_kernel_classes_Class ( $ type ) ) ; } continue ; } $ prop = new core_kernel_classes_Property ( $ propertyUri ) ; $ values = $ instance -> getPropertyValuesCollection ( $ prop ) ; if ( $ values -> count ( ) > 0 ) { if ( is_array ( $ propertyValue ) ) { $ instance -> removePropertyValues ( $ prop ) ; foreach ( $ propertyValue as $ aPropertyValue ) { $ instance -> setPropertyValue ( $ prop , $ aPropertyValue ) ; } } else if ( is_string ( $ propertyValue ) ) { $ instance -> editPropertyValues ( $ prop , $ propertyValue ) ; if ( strlen ( trim ( $ propertyValue ) ) == 0 ) { //if the property value is an empty space(the default value in a select input field), delete the corresponding triplet (and not all property values) $ instance -> removePropertyValues ( $ prop , array ( 'pattern' => '' ) ) ; } } } else { if ( is_array ( $ propertyValue ) ) { foreach ( $ propertyValue as $ aPropertyValue ) { $ instance -> setPropertyValue ( $ prop , $ aPropertyValue ) ; } } else if ( is_string ( $ propertyValue ) && strlen ( trim ( $ propertyValue ) ) !== 0 ) { $ instance -> setPropertyValue ( $ prop , $ propertyValue ) ; } } $ eventManager -> trigger ( new \ oat \ tao \ model \ event \ MetadataModified ( $ instance , $ propertyUri , $ propertyValue ) ) ; } $ returnValue = $ instance ; } catch ( common_Exception $ e ) { $ msg = "An error occured while binding property values to instance '': " . $ e -> getMessage ( ) ; $ instanceUri = $ instance -> getUri ( ) ; throw new tao_models_classes_dataBinding_GenerisInstanceDataBindingException ( $ msg ) ; } return $ returnValue ; }
Simply bind data from the source to a specific generis class instance.

The array of the data to be bound must contain keys that are property
The repspective values can be either scalar or vector (array) values or
values.

- If the element of the $data array is scalar, it is simply bound using
- If the element of the $data array is a vector, the property values are
with the values of the vector.

@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param  array data An array of values where keys are Property URIs and values are either scalar or vector values.
@return mixed
Simply bind data from the source to a specific generis class instance .