Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions framework/base/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ public function getAttributes($names = null, $except = [])
* @param array $values attribute values (name => value) to be assigned to the model.
* @param boolean $safeOnly whether the assignments should only be done to the safe attributes.
* A safe attribute is one that is associated with a validation rule in the current [[scenario]].
* @return $this
* @see safeAttributes()
* @see attributes()
*/
Expand All @@ -701,6 +702,8 @@ public function setAttributes($values, $safeOnly = true)
}
}
}

return $this;
}

/**
Expand Down
1 change: 1 addition & 0 deletions framework/db/ActiveRecordInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function getAttribute($name);
* Sets the named attribute value.
* @param string $name the attribute name.
* @param mixed $value the attribute value.
* @return $this
* @see hasAttribute()
*/
public function setAttribute($name, $value);
Expand Down
9 changes: 9 additions & 0 deletions framework/db/BaseActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,16 @@ protected function setAttributeInternal($name, $value, $check = true)
* @param string $name the attribute name
* @param mixed $value the attribute value.
* @param boolean $throw Set to false to not throw an exception (used internally).
* @return $this
* @see hasAttribute()
*/
public function setAttribute($name, $value)
{
if (!$this->setAttributeInternal($name, $value)) {
throw new InvalidParamException(get_class($this) . ' has no attribute named "' . $name . '".');
}

return $this;
}


Expand All @@ -483,10 +486,13 @@ public function getOldAttributes()
* All existing old attribute values will be discarded.
* @param array|null $values old attribute values to be set.
* If set to `null` this record is considered to be [[isNewRecord|new]].
* @return $this
*/
public function setOldAttributes($values)
{
$this->_oldAttributes = $values;

return $this;
}

/**
Expand All @@ -507,6 +513,7 @@ public function getOldAttribute($name)
* Sets the old value of the named attribute.
* @param string $name the attribute name
* @param mixed $value the old attribute value.
* @return $this
* @throws InvalidParamException if the named attribute does not exist.
* @see hasAttribute()
*/
Expand All @@ -517,6 +524,8 @@ public function setOldAttribute($name, $value)
} else {
throw new InvalidParamException(get_class($this) . ' has no attribute named "' . $name . '".');
}

return $this;
}

/**
Expand Down