public function setPersistentValue(PersistentField $field, $value)
 {
     if ($field->isCustomized()) {
         $reflector = new ReflectionClass($field->getType());
         if ($reflector->isSubclassOf('PersistentComponent')) {
             $component = $reflector->newInstance();
             $component->setInternalKey($value);
             $component->load();
         } else {
             throw new Exception("You have to use a specific translator for " . $field->getType() . " objects.");
         }
     } 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 {
                 settype($value, $field->getType());
                 $field->set($value);
             }
         }
     }
 }
Exemplo n.º 2
0
 public function setPersistentValue(PersistentField $field, $value)
 {
     if ($value === null) {
         $field->set(null);
     } else {
         $field->set(TeamMember::getMember(intval($value)));
     }
 }