public function __construct($name, $value = null) { $this->name = PersistentField::stringField(100)->forget()->key()->lock(); $this->value = PersistentField::stringField(100)->forget()->lock(); if (empty($name)) { throw new Exception("The property must have a name"); } $this->name = $name; $this->value = $value; }
public function getPersistentTable(PersistentField $field) { if ($field->isBoolean()) { return PersistentTable::defaultBooleanTable(); } else { if ($field->isInteger()) { return PersistentTable::defaultIntegerTable(); } else { if ($field->isDouble()) { return PersistentTable::defaultDoubleTable(); } else { if ($field->isString()) { return PersistentTable::defaultStringTable($field->getLength()); } else { if ($field->isArray()) { throw new Exception("Array management is not implemented yet."); } else { if ($field->isResource()) { throw new Exception("Resource management is not implemented yet."); } else { if ($field->isCustomized()) { if ($field->get() instanceof PersistentComponent) { return PersistentTable::defaultIntegerTable(); } else { throw new Exception("You have to use a specific translator for " . $field->getType() . " objects."); } } } } } } } } }
public function addPersistentField(PersistentField $descriptor) { $class = $descriptor->getClass(); if (!array_key_exists($class, $this->persistentFields)) { $this->persistentFields[$class] = array(); } $field = $descriptor->getName(); if (!array_key_exists($field, $this->persistentFields[$class])) { $this->persistentFields[$class][$field] = $descriptor; $descriptor->lock(); } else { throw new Exception("The descriptor ({$class}, {$field}) already exists."); } }
public function setPersistentValue(PersistentField $field, $value) { if ($value === null) { $field->set(null); } else { $field->set(TeamMember::getMember(intval($value))); } }