Exemple #1
0
 /**
  * DM2 creation callback, binds to the current content topic.
  */
 function &dm2_create_callback(&$controller)
 {
     $create_type = $this->_new_type;
     $this->_new_object = new $create_type();
     if ($this->_object) {
         if ($this->_new_type == 'midcom_db_parameter') {
             // Parameters are linked a bit differently
             $this->_new_object->parentguid = $this->_object->guid;
         } else {
             // Figure out the linking property
             $link_info = $this->_find_linking_property($create_type);
             if (!is_array($link_info)) {
                 throw new midcom_error("Could not establish link between {$create_type} and " . get_class($this->_object));
             }
             $child_property = $link_info[0];
             $parent_property = $link_info[1];
             $this->_new_object->{$child_property} = $this->_object->{$parent_property};
         }
     }
     if (!$this->_new_object->create()) {
         debug_print_r('We operated on this object:', $this->_new_object);
         throw new midcom_error('Failed to create a new object. Last Midgard error was: ' . midcom_connection::get_error_string());
     }
     return $this->_new_object;
 }