From c4c81753f9e2005073e7b27bec6d78bc221a612e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 16 Aug 2006 00:04:10 +0000 Subject: [PATCH] - Making SharedInstance() static-friendly - Switch to exceptions --- Loader.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Loader.php b/Loader.php index 6b16b36..c0a7e27 100644 --- a/Loader.php +++ b/Loader.php @@ -43,7 +43,7 @@ class BSLoader * Singleton instance * @var object */ - private $instance; + private static $instance; /** * Array of all the registers @@ -71,11 +71,11 @@ class BSLoader */ private function SharedInstance() { - if (!$this->instance) + if (!self::$instance) { - $this->instance = self::__construct(); + self::$instance = new BSLoader; } - return $this->instance; + return self::$instance; } // ################################################################### @@ -114,7 +114,7 @@ class BSLoader { if (get_class($newreg) != 'BSRegister') { - trigger_error('BSLoader::SetRegister() was not passed a BSRegister object', E_USER_ERROR); + throw new Exception('BSLoader::SetRegister() was not passed a BSRegister object'); } self::SharedInstance()->main = $register; @@ -135,7 +135,7 @@ class BSLoader { if (!isset(self::SharedInstance()->main)) { - trigger_error('Cannot fetch the main register because it has not been set with BSLoader::SetRegister()', E_USER_ERROR); + throw new Exception('Cannot fetch the main register because it has not been set with BSLoader::SetRegister()'); } return self::SharedInstance()->main; } @@ -143,7 +143,7 @@ class BSLoader { if (!isset(self::SharedInstance()->registers["$index"])) { - trigger_error('Invalid register index passed to BSLoader::GetRegister()', E_USER_ERROR); + throw new Exception('Invalid register index passed to BSLoader::GetRegister()'); } return self::SharedInstance()->registers["$index"]; } @@ -161,7 +161,7 @@ class BSLoader { if (!file_exists("ISSO/$name.php")) { - trigger_error('Specified module does not exist', E_USER_ERROR); + throw new Exception('Specified module does not exist'); } require_once("ISSO/$name.php"); @@ -170,7 +170,7 @@ class BSLoader if (!class_exists($class)) { - trigger_error('Specifed module does not conform to the ISSO specification, or the class is missing', E_USER_ERROR); + throw new Exception('Specifed module does not conform to the ISSO specification, or the class is missing'); } return new $class; -- 2.22.5