Beispiel #1
0
 public function reverseMap($object, $disableMappingExceptions = false)
 {
     $keys = get_object_vars($this);
     foreach ($keys as $key => $value) {
         $method = "setO_" . $key;
         if (method_exists($object, $method)) {
             $object->{$method}($value);
         }
     }
     //must be after generic setters above!!
     parent::reverseMap($object, $disableMappingExceptions);
     if (is_array($this->elements)) {
         foreach ($this->elements as $element) {
             $class = "Object_Class_Data_" . ucfirst($element->type);
             if (Pimcore_Tool::classExists($class)) {
                 $setter = "set" . ucfirst($element->name);
                 if (method_exists($object, $setter)) {
                     $tag = $object->getO_class()->getFieldDefinition($element->name);
                     if ($class instanceof Object_Class_Data_Fieldcollections) {
                         $object->{$setter}($tag->getFromWebserviceImport($element->fieldcollection));
                     } else {
                         $object->{$setter}($tag->getFromWebserviceImport($element->value, $object));
                     }
                 } else {
                     if (!$disableMappingExceptions) {
                         throw new Exception("Unable to reverse map element [ " . $element->name . " ] of type [ " . $element->type . " ]. Setter not found");
                     }
                 }
             } else {
                 if (!$disableMappingExceptions) {
                     throw new Exception("Unable to reverse map element [ " . $element->name . " ] of type [ " . $element->type . " ]. Object_Class_Data type not found. ");
                 }
             }
         }
     }
 }
Beispiel #2
0
 /**
  * @param Webservice_Data_Object $wsDocument
  * @return bool
  */
 protected function updateObject($wsDocument)
 {
     $object = Object_Abstract::getById($wsDocument->id);
     $this->setModificationParams($object, false);
     if ($object instanceof Object_Concrete and $object->getO_className() == $wsDocument->className) {
         $wsDocument->reverseMap($object);
         $object->save();
         return true;
     } else {
         if ($object instanceof Object_Folder and $object->getType() == strtolower($wsDocument->type)) {
             $wsDocument->reverseMap($object);
             $object->save();
             return true;
         } else {
             if ($object instanceof Object_Abstract) {
                 throw new Exception("Type/Class mismatch for given object with ID [" . $wsDocument->id . "] and existing object with id [" . $object->getId() . "]");
             } else {
                 throw new Exception("Object with given ID (" . $wsDocument->id . ") does not exist.");
             }
         }
     }
 }