From: Michael J. Rubinsky Date: Mon, 23 Nov 2009 18:49:49 +0000 (-0500) Subject: Don't return anything if the proerty doesn't exist, thrown an exception instead. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a592e6cc374d33e7547b92c22c4074ab67242ab3;p=horde.git Don't return anything if the proerty doesn't exist, thrown an exception instead. Also provide defaults for most properties, just in case. --- diff --git a/kronolith/lib/Resource/Base.php b/kronolith/lib/Resource/Base.php index 9d15abb17..966611ad2 100644 --- a/kronolith/lib/Resource/Base.php +++ b/kronolith/lib/Resource/Base.php @@ -15,8 +15,6 @@ abstract class Kronolith_Resource_Base * description - * email - * response_type - a RESPONSETYPE_* constant - * category - The category of this resource...an arbitrary label used - * to group multiple resources for the resource_group implementation * * @var array */ @@ -43,8 +41,16 @@ abstract class Kronolith_Resource_Base $this->_id = $params['id']; } + // Names are required. + if (empty($params['name'])) { + throw new Horde_Exception('Required \'name\' attribute missing from resource calendar'); + } + array_merge($params, array('description' => '', - 'category' => '')); + 'response_type' => Kronolith_Resource::RESPONSETYPE_MANUAL, + 'members' => '', + 'type' => Kronolith_Resource::TYPE_SINGLE)); + $this->_params = $params; } @@ -101,7 +107,10 @@ abstract class Kronolith_Resource_Base return ($this instanceof Kronolith_Resource_Single) ? 'Single' : 'Group'; } - return !empty($this->_params[$property]) ? $this->_params[$property] : false; + if (!isset($this->_params[$property])) { + throw new Horde_Exception(sprintf("The property \'%s\' does not exist", $property)); + } + return $this->_params[$property]; } /**