Skip to content
Snippets Groups Projects
Commit afc31fcb authored by Jared Hancock's avatar Jared Hancock
Browse files

orm: Make __get() and get() consistent

parent 102f69e0
No related branches found
No related tags found
No related merge requests found
......@@ -748,7 +748,7 @@ class DynamicFormEntryAnswer extends VerySimpleModel {
}
function getValue() {
if (!$this->_value)
if (!$this->_value && isset($this->value))
$this->_value = $this->getField()->to_php(
$this->get('value'), $this->get('value_id'));
return $this->_value;
......
......@@ -36,10 +36,7 @@ class VerySimpleModel {
$this->dirty = array();
}
function get($field) {
return $this->ht[$field];
}
function __get($field) {
function get($field, $default=false) {
if (array_key_exists($field, $this->ht))
return $this->ht[$field];
elseif (isset(static::$meta['joins'][$field])) {
......@@ -50,9 +47,14 @@ class VerySimpleModel {
array($j['fkey'][1] => $this->ht[$j['local']]));
return $v;
}
if (isset($default))
return $default;
throw new OrmException(sprintf('%s: %s: Field not defined',
get_class($this), $field));
}
function __get($field) {
return $this->get($field, null);
}
function __isset($field) {
return array_key_exists($field, $this->ht)
......@@ -78,7 +80,7 @@ class VerySimpleModel {
$this->ht[$field] = $value;
// Capture the foreign key id value
$field = $j['local'];
$value = $value->{$j['fkey'][1]};
$value = $value->get($j['fkey'][1]);
// Fall through to the standard logic below
}
// XXX: Fully support or die if updating pk
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment