Skip to content

Commit

Permalink
Add lithium\data\Entity::__unset().
Browse files Browse the repository at this point in the history
  • Loading branch information
jails committed Aug 5, 2014
1 parent 1196db6 commit af1760a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions data/Entity.php
Expand Up @@ -199,6 +199,21 @@ public function __isset($name) {
return isset($this->_updated[$name]) || isset($this->_relationships[$name]);
}

/**
* PHP magic method used when unset() is called on a `Entity` instance.
* Use case for this would be when you wish to edit a document and remove a field, ie.:
* {{{
* $entity = Post::find($id);
* unset($entity->fieldName);
* $entity->save();
* }}}
*
* @param string $name The name of the field to remove.
*/
public function __unset($name) {
unset($this->_updated[$name]);
}

/**
* Magic method that allows calling of model methods on this record instance, i.e.:
* {{{
Expand Down

0 comments on commit af1760a

Please sign in to comment.