public static function restore($props) { $rv =& new Caddy(); foreach ($props['items'] as $key => $value) { $rv->addCaddyItem(StoreObject::restore($value)); } return $rv; }
public static function restore($props) { $rv =& new FormInputConfiguration(); foreach ($props['items'] as $key => $value) { $rv->add(StoreObject::restore($value)); } return $rv; }
public static function restore($props) { $rv =& FormInputFabrication::createNew($props['type'], $props['name']); $rv->_value = $props['value']; $rv->_default_value = $props['default_value']; $rv->_configuration = StoreObject::restore($props['configuration']); return $rv; }
public static function restore($props) { try { $value = StoreObject::restore($props['value']); } catch (TypeMismatchException $e) { $value = $props['value']; } return new CaddyItemFeature($props['key'], $value); }
public function save(&$caddyId = null) { $rv = false; if (is_null($this->_caddy)) { throw new Exception('No caddy to save'); } if (is_null($caddyId)) { $caddyId = $this->_caddy_id; } $blob_data = StoreObject::store($this->_caddy); $date = date('Y-m-d H:i:s'); $sql =& new sqlBuilder(); if (is_null($caddyId)) { // On insère $sql->set('date_creation', $date, sqlBuilder::SqlTypeDate); $sql->set('date_update', $date, sqlBuilder::SqlTypeDate); $sql->set('blob_caddy', $blob_data, sqlBuilder::SqlTypeString); $rv = $this->_storage->execute($sql->insert('Caddy')); if ($rv) { $this->_caddy_id = $this->_storage->getLastRowIdentifier(); $this->_date_creation = $this->_date_update = $date; } } else { $alias = $sql->aliasTable('Caddy', 'c'); $sql->get($alias, 'date_creation'); $sql->whereField($alias, 'id_caddy', $caddyId, '=', sqlBuilder::AndOperator); if ($rs =& $this->_storage->execute($sql->select())) { $sql->reset(); if ($rs->hasNext()) { // On update $rs->dispose(); $alias = $sql->aliasTable('Caddy', 'c'); $sql->set('date_update', $date, sqlBuilder::SqlTypeDate); $sql->set('blob_caddy', $blob_data, sqlBuilder::SqlTypeString); $sql->whereField($alias, 'id_caddy', $caddyId, '=', sqlBuilder::AndOperator); $rv = $this->_storage->execute($sql->update($alias)); if ($rv) { $this->_date_update = $date; } } else { // On insère $sql->set('date_creation', $date, sqlBuilder::SqlTypeDate); $sql->set('date_update', $date, sqlBuilder::SqlTypeDate); $sql->set('blob_caddy', $blob_data, sqlBuilder::SqlTypeString); $rv = $this->_storage->execute($sql->insert('Caddy')); if ($rv) { $this->_caddy_id = $this->_storage->getLastRowIdentifier(); $this->_date_creation = $this->_date_update = $date; } } } } return $rv; }
public function save(&$caddyId = null) { $rv = false; if (is_null($this->_caddy)) { throw new Exception('No caddy to save'); } if (is_null($caddyId)) { $caddyId = $this->_caddy_id; } $blob_data = StoreObject::store($this->_caddy); $date = date('Y-m-d H:i:s'); $xml =& $this->_storage->getResource(); $root =& $xml->getDocumentElement(); if (is_null($caddyId)) { // On insère $child =& $xml->createElement('caddy'); $child->setAttribute('id', $caddyId); $child->setAttribute('date_creation', $date); $child->setAttribute('date_update', $date); $text =& $xml->createTextNode($blob_data); $child->appendChild($text); $root->appendChild($child); $this->_date_creation = $this->_date_update = $date; } else { $child = $xml->getElementById($caddyId); if (!is_null($child)) { // On update $child->setAttribute('date_update', $date); if ($child->hasChildNodes()) { $child->removeChild($child->firstChild()); } $text =& $xml->createTextNode($blob_data); $child->appendChild($text); $this->_date_update = $date; } else { // On insère $child =& $xml->createElement('caddy'); $child->setAttribute('id', $caddyId); $child->setAttribute('date_creation', $date); $child->setAttribute('date_update', $date); $text =& $xml->createTextNode($blob_data); $child->appendChild($text); $root->appendChild($child); $this->_date_creation = $this->_date_update = $date; } } return $xml->toFile($this->_storage->getDriver()->getFilepath()); }
public static function restore($props) { $rv =& new CaddyItem($props['key'], $props['quantity'], $props['price']); foreach ($props['features'] as $key => $value) { $rv->addCaddyItemFeature(StoreObject::restore($value)); } return $rv; }