+ Added dependencies to model for reset calculated properties
This commit is contained in:
parent
58a39ccc48
commit
dbd0fe8535
1 changed files with 14 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue