Example #1
0
 /**
  * Assign the UUID for this object. Set it to null to clear it in order to have
  * it regenerated on the next call to getUuid().
  *
  * @param mixed $uuid The UUID to assign (or null to regenerate).
  */
 public function setUuid($uuid = null)
 {
     if ($uuid === null) {
         $this->_object_uuid = null;
         return true;
     }
     if (!UuidGenerator::valid($uuid)) {
         throw new \UnexpectedValueException("Assigned value is not a valid UUID: {$uuid}");
     }
     $this->_object_uuid = $uuid;
     return true;
 }
Example #2
0
 public static function registerService($i, $upgrade = false)
 {
     $db = self::getDbInstance();
     $id = $i->getServiceId();
     $cn = get_class($i);
     if (count($db->query("SELECT * FROM services WHERE id=%s", $id)->fetchAll()) > 0) {
         if (!$upgrade) {
             throw new \Exception("Service with id {$id} already registered.");
         }
         $db->query("DELETE FROM services WHERE id=%s", $id);
     }
     $db->query("INSERT INTO services (id,uuid,serviceclass,baseinstance) VALUES (%s,%s,%s,%s)", $id, \Cherry\Crypto\UuidGenerator::uuid(), $cn, base64_encode(serialize($i)));
     //self::$sinstances[$id] = serialize($i);
 }