You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
33
extend/app_alipay/lotusphp_runtime/ObjectUtil/ObjectUtil.php
Executable file
33
extend/app_alipay/lotusphp_runtime/ObjectUtil/ObjectUtil.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
class LtObjectUtil
|
||||
{
|
||||
static $instances;
|
||||
|
||||
static public function singleton($className, $autoInited = true)
|
||||
{
|
||||
if (empty($className))
|
||||
{
|
||||
trigger_error('empty class name');
|
||||
return false;
|
||||
}
|
||||
$key = strtolower($className);
|
||||
if (isset(self::$instances[$key]))
|
||||
{
|
||||
return self::$instances[$key];
|
||||
}
|
||||
else if (class_exists($className))
|
||||
{
|
||||
$newInstance = new $className;
|
||||
if ($autoInited && method_exists($newInstance, 'init'))
|
||||
{
|
||||
$newInstance->init();
|
||||
}
|
||||
self::$instances[$key] = $newInstance;
|
||||
return $newInstance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user