/** * Constructor. * * @see Horde_Exception::__construct() * * @param mixed $message The exception message, a PEAR_Error * object, or an Exception object. * @param integer $code A numeric error code. */ public function __construct($message = null, $code = null) { if (is_null($message)) { $message = Horde_Exception_Translation::t("Not Found"); } parent::__construct($message, $code); }
/** * Return a cost object hash. * * @param string $id The cost object id. * * @return array The cost object hash. Keys differ depending on the * API queried, but should always contain: * - id: * - name: * * @throws Horde_ExceptionNotFound */ public static function getCostObjectByID($id) { static $cost_objects; if (strpos($id, ':') !== false) { list($app, $app_id) = explode(':', $id, 2); if (!isset($cost_objects[$app])) { $results = $GLOBALS['registry']->callByPackage($app, 'listCostObjects', array(array())); $cost_objects[$app] = $results; } foreach (array_keys($cost_objects[$app]) as $catkey) { foreach (array_keys($cost_objects[$app][$catkey]['objects']) as $objkey) { if ($cost_objects[$app][$catkey]['objects'][$objkey]['id'] == $app_id) { return $cost_objects[$app][$catkey]['objects'][$objkey]; } } } } throw new Horde_Exception_NotFound(sprintf('%s (%s)', Horde_Exception_Translation::t("Not Found"), $id)); }