From 779061241c5075a990c2a7c27eb4102f5b8f0f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Sat, 2 Feb 2008 14:11:27 +0000 Subject: [PATCH] modified the configuration class so it allows multiple simultanous instances. This is important in the case where you write a separate application that makes use of simplesamlphp and also make use of the simplesamlphp libraries as the template system where the template directory is not the same as for simplesamlphp itself. I am writing an application called openwiki where this is important. should not break existing code, and no modifications neccessary in other simplesamlphp files. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@239 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Configuration.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index 49035292d..713a79737 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -9,24 +9,24 @@ */ class SimpleSAML_Configuration { - private static $instance = null; + private static $instance = array(); private $configpath = null; private $configuration = null; // private constructor restricts instantiaton to getInstance() private function __construct($configpath) { - $this->configpath = $configpath; - } - public static function getInstance() { - return self::$instance; + public static function getInstance($instancename = 'simplesaml') { + if (!array_key_exists($instancename, self::$instance)) + throw new Exception('Configuration with name ' . $instancename . ' is not initialized.'); + return self::$instance[$instancename]; } - public static function init($path) { - self::$instance = new SimpleSAML_Configuration($path); + public static function init($path, $instancename = 'simplesaml') { + self::$instance[$instancename] = new SimpleSAML_Configuration($path); } private function loadConfig() { -- GitLab