+ Added dependencies to model for reset calculated properties

This commit is contained in:
Visman 2018-11-07 18:30:29 +07:00
parent 58a39ccc48
commit dbd0fe8535

View file

@ -25,6 +25,12 @@ class Model
*/
protected $aCalc = [];
/**
* Зависимости свойств
* @var array
*/
protected $dependProp = [];
/**
* Конструктор
*
@ -58,6 +64,10 @@ class Model
{
unset($this->a[$name]); //????
unset($this->aCalc[$name]); //????
if (isset($this->dependProp[$name])) {
$this->aCalc = \array_diff_key($this->aCalc, \array_flip($this->dependProp[$name]));
}
}
/**
@ -70,6 +80,10 @@ class Model
{
unset($this->aCalc[$name]);
if (isset($this->dependProp[$name])) {
$this->aCalc = \array_diff_key($this->aCalc, \array_flip($this->dependProp[$name]));
}
if (\method_exists($this, $method = 'set' . $name)) {
$this->$method($val);
} else {