]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/loader/class_ClassLoader.php
Rewrite of initInstance(), more eval() rewritten to call_user_func_array()
[shipsimu.git] / inc / loader / class_ClassLoader.php
index a82f95118f01bdfea6607487fd34e64a87ecfca3..06d2bb29e97ce02f35a9eaa0645a45af3587a509 100644 (file)
@@ -88,7 +88,7 @@ class ClassLoader {
        /**
         * Instance of this class
         */
-       private static $thisInstance = null;
+       private static $selfInstance = null;
 
        /**
         * The *public* constructor
@@ -115,16 +115,23 @@ class ClassLoader {
                $this->classes = new ArrayObject();
 
                // Set own instance
-               self::$thisInstance = $this;
+               self::$selfInstance = $this;
        }
 
        /**
         * Getter for an instance of this class
         *
-        * @return      $thisInstance           An instance of this class
+        * @return      $selfInstance           An instance of this class
         */
        public final static function getInstance () {
-               return self::$thisInstance;
+               // Is the instance there?
+               if (is_null(self::$selfInstance)) {
+                       // Get a new one
+                       self::$selfInstance = new ClassLoader(FrameworkConfiguration::getInstance());
+               } // END - if
+
+               // Return the instance
+               return self::$selfInstance;
        }
 
        /**
@@ -179,14 +186,14 @@ class ClassLoader {
 
                                // Scan the directory
                                $this->scanLocalPath($currPath);
-                       }
+                       } // END - for
 
                        // Check if we can leave
                        $cnt = 0;
                        for ($idx = $this->dirList->getIterator(); $idx->valid(); $idx->next()) {
                                if ($idx->current() == "") $cnt++;
-                       }
-               }
+                       } // END - for
+               } // END - while
        }
 
        /**
@@ -225,11 +232,7 @@ class ClassLoader {
                        } elseif (is_dir($dirClass) && !in_array($dirClass2, $this->ignoreList)) {
                                // Directory found and added to list
                                //* DEBUG: */ print "DIR={$dirClass}\n";
-                               if ($dirClass2 == "interfaces") {
-                                       $this->scanLocalPath($dirClass);
-                               } else {
-                                       $this->dirList->append($dirClass);
-                               }
+                               $this->dirList->append($dirClass);
                                $this->dirCnt++;
                        }
                        //* DEBUG: */ print "LOOP!\n";
@@ -237,6 +240,7 @@ class ClassLoader {
 
                // Close directory handler
                $dirInstance->closeDirectory();
+               unset($dirInstance);
 
                // Output counter in debug mode
                if (defined('DEBUG_MODE')) print(sprintf("[%s:] <strong>%d</strong> Klassendateien in <strong>%d</strong> Verzeichnissen gefunden und geladen.<br />\n",
@@ -257,11 +261,11 @@ class ClassLoader {
                                // Load current class
                                //* DEBUG: */ print "Class=".$idx->current()."\n";
                                require_once($idx->current());
-                       }
+                       } // END - for
 
                        // Re-initialize the classes list
                        $this->classes = new ArrayObject();
-               }
+               } // END - if
        }
 
        /**
@@ -294,8 +298,5 @@ require_once(sprintf("%sinc/classes/interfaces/class_FrameworkInterface%s", PATH
 require_once(sprintf("%sinc/classes/main/class_BaseFrameworkSystem%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
 require_once(sprintf("%sinc/classes/main/io/class_FrameworkDirectoryPointer%s", PATH, FrameworkConfiguration::getInstance()->readConfig('php_extension')));
 
-// Initialize the class loader
-$loader = new ClassLoader(FrameworkConfiguration::getInstance());
-
 // [EOF]
 ?>