Commit e160a772e228ef5a337d796077d6e0946b36bbef

Authored by Neil Blakey-Milner
1 parent 15d86d08

getObject is a way to get an object when you don't know if you have the

object or its unique identifier.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3748 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 13 additions and 0 deletions
lib/util/ktutil.inc
... ... @@ -295,6 +295,19 @@ class KTUtil {
295 295 }
296 296 // }}}
297 297  
  298 + // {{{ getObject
  299 + function getObject($sClassName, &$iId) {
  300 + if (is_object($iId)) {
  301 + return $iId;
  302 + }
  303 +
  304 + if (is_numeric($iId)) {
  305 + return call_user_func(array($sClassName, 'get'), $iId);
  306 + }
  307 + return PEAR::raiseError('Non-entity object');
  308 + }
  309 + // }}}
  310 +
298 311 // {{{ meldOptions
299 312 function meldOptions($aStartOptions, $aAddOptions) {
300 313 if (!is_array($aStartOptions)) {
... ...