From af1760a506cf51a6970f139e5e61a1a8ad258292 Mon Sep 17 00:00:00 2001 From: Simon JAILLET Date: Mon, 22 Jul 2013 18:04:41 +0200 Subject: [PATCH] Add `lithium\data\Entity::__unset()`. --- data/Entity.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data/Entity.php b/data/Entity.php index ff37bd52f1..3af8f54dfb 100644 --- a/data/Entity.php +++ b/data/Entity.php @@ -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.: * {{{