From 7f29127e778974fbb97e5f09c822a839d543f538 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Wed, 22 Apr 2009 22:57:21 +0200 Subject: [PATCH] Extract the handling of data before saving it into a separate function. This allows child classes to act after the data has been prepared for saving. --- .../Kolab_Server/lib/Horde/Kolab/Server/Object.php | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php index d3bce4e0a..3c0a002bb 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php @@ -646,6 +646,31 @@ class Horde_Kolab_Server_Object */ public function save($info) { + $info = $this->prepareInformation($info); + + $result = $this->server->save($this->uid, $info, $this->exists()); + + if (!$this->_exists) { + $this->_exists = true; + $this->_cache = $info; + } else { + $this->_cache = array_merge($this->_cache, $info); + } + + return $result; + } + + /** + * Prepare the object information before saving. + * + * @param array $info The information about the object. + * + * @return array The set of information. Ready for saving. + * + * @throws Horde_Kolab_Server_Exception If the given information contains errors. + */ + public function prepareInformation($info) + { if (!empty($this->attributes)) { foreach ($info as $key => $value) { if (!in_array($key, array_keys($this->attributes))) { @@ -738,17 +763,7 @@ class Horde_Kolab_Server_Object foreach ($this->attribute_map['collapsed'] as $key => $attributes) { $this->collapse($key, $attributes, $info); } - - $result = $this->server->save($this->uid, $info, $this->exists()); - - if (!$this->_exists) { - $this->_exists = true; - $this->_cache = $info; - } else { - $this->_cache = array_merge($this->_cache, $info); - } - - return $result; + return $info; } /** -- 2.11.0