protected function loadExisting()
{
$pk = [];
foreach ($this->_attributes as $attribute) {
if (in_array($attribute->standardAttribute->name, $this->_instance->primaryKey())) {
$pk[$attribute->standardAttribute->name] = $attribute->value;
}
}
if (!$pk) {
return;
}
if (count($pk) == 1 && !reset($pk)) {
return;
}
foreach ($pk as $value) {
if (!$value) {
throw new RowException($this->row, 'For updated model all primary key attributes must be specified.');
}
}
/* @var $modelClass \yii\db\ActiveRecord */
$modelClass = $this->_standardModel->className;
$model = $modelClass::findOne($pk);
if (!$model) {
throw new RowException($this->row, 'Model for update not found.');
}
$this->_instance = $model;
}