mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Making $_SINGLETONS a global instead of a static in Core.php so it can be re-used in other places
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73883 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
697703aff8
commit
23fc9380f2
@ -255,8 +255,20 @@ function getClassFile($className) {
|
||||
if($_CLASS_MANIFEST[$className]) return $_CLASS_MANIFEST[$className];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a class instance by the "singleton" design pattern.
|
||||
* It will always return the same instance for this class,
|
||||
* which can be used for performance reasons and as a simple
|
||||
* way to access instance methods which don't rely on instance
|
||||
* data (e.g. the custom SilverStripe static handling).
|
||||
*
|
||||
* @uses Object::strong_create()
|
||||
*
|
||||
* @param string $className
|
||||
* @return Object
|
||||
*/
|
||||
function singleton($className) {
|
||||
static $_SINGLETONS;
|
||||
global $_SINGLETONS;
|
||||
if(!isset($className)) user_error("singleton() Called without a class", E_USER_ERROR);
|
||||
if(!is_string($className)) user_error("singleton() passed bad class_name: " . var_export($className,true), E_USER_ERROR);
|
||||
if(!isset($_SINGLETONS[$className])) {
|
||||
|
Loading…
Reference in New Issue
Block a user