Ejemplo n.º 1
0
 /**
  * Start up the storage manager and bind it to a given MidgardObject.
  * The passed object must be a MidCOM DBA object, otherwise the system bails with
  * midcom_error. In this case, no automatic conversion is done, as this would
  * destroy the reference.
  *
  * @param midcom_helper_datamanager2_schema $schema The data schema to use for processing.
  * @param MidCOMDBAObject $object A reference to the DBA object to user for Data I/O.
  */
 public function __construct($schema, $object)
 {
     parent::__construct($schema);
     if (!midcom::get('dbclassloader')->is_mgdschema_object($object)) {
         debug_print_r('Object passed:', $object);
         throw new midcom_error('The midgard storage backend requires a MidCOM DBA object.');
     }
     $this->object = $object;
 }
Ejemplo n.º 2
0
 /**
  * This function will save the current state of all types to disk. A full
  * validation cycle is done beforehand, if any validation fails, the function
  * aborts and sets the $validation_errors member variable accordingly.
  *
  * @return boolean Indicating success
  */
 function save()
 {
     if (!$this->validate()) {
         debug_add(count($this->validation_errors) . ' fields have failed validation, cannot save.', MIDCOM_LOG_WARN);
         debug_print_r('Validation errors:', $this->validation_errors);
         return false;
     }
     return $this->storage->store($this->types);
 }
Ejemplo n.º 3
0
 /**
  * TODO
  *
  * @param midcom_helper_datamanager2_schema &$schema The data schema to use for processing.
  * @param Array $defaults The defaults to use as "artificial" storage. This can be omitted
  *     safely.
  */
 public function __construct(&$schema, $defaults = array())
 {
     parent::__construct($schema);
     $this->_defaults = $defaults;
 }
Ejemplo n.º 4
0
 /**
  * Checks whether the current user has the given privilege on the storage backend.
  *
  * The storage backend is responsible for the actual execution of this operation,
  * so this is merely a shortcut.
  *
  * @param string $privilege The privilege to check against.
  * @return boolean true if the user has the permission, false otherwise.
  */
 function can_do($privilege)
 {
     return $this->storage->can_do($privilege);
 }