All filters rewritten to throw FilterChainException
[core.git] / inc / classes / main / registry / class_Registry.php
index 9a8b648376ab6db4770ef4f0d3ff14a098e45e1c..d5ad6e6bb882a69baa697722107c0d31ec76c47f 100644 (file)
@@ -1,10 +1,11 @@
 <?php
 /**
 <?php
 /**
- * A registry for several data types
+ * A registry for several data types and objects. Objects should be added by
+ * addInstance() and therefore must implement the interface Registerable.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007 - 2009 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -25,7 +26,7 @@ class Registry extends BaseFrameworkSystem implements Register {
        /**
         * Instance of this class
         */
        /**
         * Instance of this class
         */
-       private static $selfInstance = null;
+       private static $registryInstance = null;
 
        /**
         * Wether the registry is initialized
 
        /**
         * Wether the registry is initialized
@@ -52,32 +53,37 @@ class Registry extends BaseFrameworkSystem implements Register {
        }
 
        /**
        }
 
        /**
-        * Singleton getter for self instance
+        * Singleton getter for self instance. This class has no factory pattern
+        * because here is no need for special parameters.
         *
         *
-        * @return      $selfInstance   Instance of this class
+        * @return      $registryInstance       Instance of this class
         */
        public final static function getRegistry () {
                // Is an instance there?
         */
        public final static function getRegistry () {
                // Is an instance there?
-               if (is_null(self::$selfInstance)) {
+               if (is_null(self::$registryInstance)) {
                        // Not yet, so create one
                        // Not yet, so create one
-                       self::$selfInstance = new Registry();
-               }
+                       self::$registryInstance = new Registry();
+               } // END - if
 
                // Return the instance
 
                // Return the instance
-               return self::$selfInstance;
+               return self::$registryInstance;
        }
 
        /**
        }
 
        /**
-        * Checks or sets wether the registry has been initialized. This had only be done once
+        * Checks or sets wether the registry has been initialized. This had only
+        * be done once.
         *
         * @param       $initialized    Wether the registry is initialized
         * @return      $initialized    Wether the registry is initialized
         */
        public final static function isInitialized ($initialized = null) {
         *
         * @param       $initialized    Wether the registry is initialized
         * @return      $initialized    Wether the registry is initialized
         */
        public final static function isInitialized ($initialized = null) {
+               // If no parameter (null by default) is provided we want to get the
+               // parameter. If set to e.g. "OK" then the registry is set to
+               // "initialized".
                if (is_null($initialized)) {
                        // Get status if initialized
                        return self::$initialized;
                if (is_null($initialized)) {
                        // Get status if initialized
                        return self::$initialized;
-               } elseif (!is_null($initialized)) {
+               } else {
                        // Registry is initialized!
                        self::$initialized = true;
                }
                        // Registry is initialized!
                        self::$initialized = true;
                }
@@ -121,7 +127,7 @@ class Registry extends BaseFrameworkSystem implements Register {
                // Is the instance there?
                if ($this->instanceExists($instanceKey)) {
                        $objectInstance = $this->instanceRegistry[$instanceKey];
                // Is the instance there?
                if ($this->instanceExists($instanceKey)) {
                        $objectInstance = $this->instanceRegistry[$instanceKey];
-               }
+               } // END - if
 
                // Return the result
                return $objectInstance;
 
                // Return the result
                return $objectInstance;