/** * Simply bind data from a Generis Instance Form to a specific generis class * * 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. * - If the element is an object, the binder will infer the best method to * it in the persistent memory, depending on its nature. * * @access public * @author Jerome Bogaerts <*****@*****.**> * @param array data An array of values where keys are Property URIs and values are either scalar, vector or object values. * @return mixed */ public function bind($data) { $returnValue = null; try { $instance = parent::bind($data); // Take care of what the generic data binding did not. foreach ($data as $p => $d) { $property = new core_kernel_classes_Property($p); if ($d instanceof tao_helpers_form_data_UploadFileDescription) { $this->bindUploadFileDescription($property, $d); } } $returnValue = $instance; } catch (common_Exception $e) { $msg = "An error occured while binding property values to instance '': " . $e->getMessage(); throw new tao_models_classes_dataBinding_GenerisFormDataBindingException($msg); } return $returnValue; }
/** * Helper to save class and properties * * @param core_kernel_classes_Resource $resource * @param array $values */ protected function bindProperties(core_kernel_classes_Resource $resource, $values) { $binder = new tao_models_classes_dataBinding_GenerisInstanceDataBinder($resource); $binder->bind($values); }
/** * bind the given RDFS properties to the RDFS resource in parameter * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @param Resource instance * @param array properties * @return core_kernel_classes_Resource */ public function bindProperties(core_kernel_classes_Resource $instance, $properties = array()) { $binder = new tao_models_classes_dataBinding_GenerisInstanceDataBinder($instance); $binder->bind($properties); return $instance; }