Code optimization

This commit is contained in:
Klimov Paul
2015-05-26 12:00:28 +03:00
parent 51a442d6c8
commit 467596633d

View File

@@ -721,13 +721,14 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
throw new StaleObjectException('The object being updated is outdated.');
}
if (isset($values[$lock])) {
$this->$lock = $values[$lock];
}
$changedAttributes = [];
foreach ($values as $name => $value) {
$changedAttributes[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null;
$this->_oldAttributes[$name] = $value;
if ($name === $lock) {
$this->$lock = $value;
}
}
$this->afterSave(false, $changedAttributes);