|
|
|
@ -131,6 +131,21 @@ class SaveRelationsBehavior extends Behavior
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set the named single relation with the given value |
|
|
|
|
* @param $name |
|
|
|
|
* @param $value |
|
|
|
|
*/ |
|
|
|
|
protected function setSingleRelation($name, $value) |
|
|
|
|
{ |
|
|
|
|
$relation = $this->owner->getRelation($name); |
|
|
|
|
if (!($value instanceof $relation->modelClass)) { |
|
|
|
|
$value = $this->processModelAsArray($value, $relation); |
|
|
|
|
} |
|
|
|
|
$this->_newRelationValue[$name] = $value; |
|
|
|
|
$this->owner->populateRelation($name, $value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set the named multiple relation with the given value |
|
|
|
|
* @param $name |
|
|
|
|
* @param $value |
|
|
|
@ -218,21 +233,6 @@ class SaveRelationsBehavior extends Behavior
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set the named single relation with the given value |
|
|
|
|
* @param $name |
|
|
|
|
* @param $value |
|
|
|
|
*/ |
|
|
|
|
protected function setSingleRelation($name, $value) |
|
|
|
|
{ |
|
|
|
|
$relation = $this->owner->getRelation($name); |
|
|
|
|
if (!($value instanceof $relation->modelClass)) { |
|
|
|
|
$value = $this->processModelAsArray($value, $relation); |
|
|
|
|
} |
|
|
|
|
$this->_newRelationValue[$name] = $value; |
|
|
|
|
$this->owner->populateRelation($name, $value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Before the owner model validation, save related models. |
|
|
|
|
* For `hasOne()` relations, set the according foreign keys of the owner model to be able to validate it |
|
|
|
|
* @param ModelEvent $event |
|
|
|
|