public
Created

Exemple of Record::__get()

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
public function &__get($name) {
$value = parent::__get($name);
if (is_array($value) && ($model = $this->_model) && ($relname = $model::relationship($name))) {
$rel = $model::relations($relname);
$type = $rel->type();
$modelTo = $rel->to();
if ($type == 'hasOne' || $type == 'belongsTo') {
$value = $model::connection()->item($modelTo, $value, array('class' => 'entity'));
} else {
$value = $model::connection()->item($modelTo, $value, array('class' => 'set'));
}
$this->_updated[$name] = $value;
}
return $value;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.