+ Added a way to get the original value of a single property for a DataModel

This commit is contained in:
Visman 2018-10-31 19:00:05 +07:00
parent b5d0d18f50
commit 0b13e3562d

View file

@ -91,7 +91,7 @@ class DataModel extends Model
// без отслеживания
if (\strpos($name, '__') === 0) {
$track = null;
$name = substr($name, 2);
$name = \substr($name, 2);
// с отслеживанием
} else {
$track = false;
@ -117,4 +117,21 @@ class DataModel extends Model
$this->modified[$name] = true;
}
}
/**
* Возвращает значение свойства
*
* @param string $name
*
* @return mixed
*/
public function __get($name)
{
if (\strpos($name, '__') === 0) {
$name = \substr($name, 2);
return isset($this->a[$name]) ? $this->a[$name] : null;
} else {
return parent::__get($name);
}
}
}