From c32203018e5d26ffe00242fb414257debc6c90e8 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 20 Jun 2008 10:37:06 +0000 Subject: [PATCH] Configuration: Allow the same configuration to be loaded multiple times. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@674 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Configuration.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index 97521d380..5996147cb 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -33,10 +33,20 @@ class SimpleSAML_Configuration { } public static function init($path, $instancename = 'simplesaml', $configfilename = 'config.php') { + /* Check if we already have loaded the given config - return the existing instance if we have. */ + if(array_key_exists($instancename, self::$instance)) { + return self::$instance[$instancename]; + } + self::$instance[$instancename] = new SimpleSAML_Configuration($path, $configfilename); } public function copyFromBase($instancename, $filename) { + /* Check if we already have loaded the given config - return the existing instance if we have. */ + if(array_key_exists($instancename, self::$instance)) { + return self::$instance[$instancename]; + } + self::$instance[$instancename] = new SimpleSAML_Configuration($this->configpath, $filename); return self::$instance[$instancename]; } -- GitLab