From e160a772e228ef5a337d796077d6e0946b36bbef Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Thu, 6 Oct 2005 19:18:24 +0000 Subject: [PATCH] getObject is a way to get an object when you don't know if you have the object or its unique identifier. --- lib/util/ktutil.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+), 0 deletions(-) diff --git a/lib/util/ktutil.inc b/lib/util/ktutil.inc index f437ede..c8df98c 100644 --- a/lib/util/ktutil.inc +++ b/lib/util/ktutil.inc @@ -295,6 +295,19 @@ class KTUtil { } // }}} + // {{{ getObject + function getObject($sClassName, &$iId) { + if (is_object($iId)) { + return $iId; + } + + if (is_numeric($iId)) { + return call_user_func(array($sClassName, 'get'), $iId); + } + return PEAR::raiseError('Non-entity object'); + } + // }}} + // {{{ meldOptions function meldOptions($aStartOptions, $aAddOptions) { if (!is_array($aStartOptions)) { -- libgit2 0.21.4