]> git.mxchange.org Git - core.git/blobdiff - inc/loader/class_ClassLoader.php
Copyright updated
[core.git] / inc / loader / class_ClassLoader.php
index 134b8c10d4af9d7a533065d105da41c4f92c09c6..e15f52d4b65f6eb79fa2b60a6762404e7ff4b7e2 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @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
  *
@@ -209,22 +209,18 @@ class ClassLoader {
         * Scans recursively a local path for class files which must have a prefix and a suffix as given by $this->suffix and $this->prefix
         *
         * @param       $basePath               The relative base path to 'base_path' constant for all classes
-        * @param       $ignoreList             An optional list (array or string) of directory names which shall be ignored
+        * @param       $ignoreList             An optional list (array forced) of directory and file names which shall be ignored
         * @return      void
         */
-       public function loadClasses ($basePath, $ignoreList = array() ) {
+       public function loadClasses ($basePath, array $ignoreList = array() ) {
                // Is a list has been restored from cache, don't read it again
                if ($this->listCached === true) {
                        // Abort here
                        return;
                }
 
-               // Convert string to array
-               if (!is_array($ignoreList)) $ignoreList = array($ignoreList);
-
                // Directories which our class loader ignores by default while
-               // deep-scanning the directory structure. See scanLocalPath() for
-               // details.
+               // deep-scanning the directory structure.
                $ignoreList[] = ".";
                $ignoreList[] = "..";
                $ignoreList[] = ".htaccess";
@@ -307,8 +303,8 @@ class ClassLoader {
                $fileName = $this->prefix . $className . $this->suffix;
 
                // Now look it up in our index
-               if (isset($this->classes[$fileName])) {
-                       // File is found so load it only once
+               if ((isset($this->classes[$fileName])) && (!in_array($this->classes[$fileName], $this->loadedClasses))) {
+                       // File is found and not loaded so load it only once
                        //* DEBUG: */ echo "LOAD: ".$fileName." - Start<br />\n";
                        require($this->classes[$fileName]);
                        //* DEBUG: */ echo "LOAD: ".$fileName." - End<br />\n";
@@ -319,6 +315,9 @@ class ClassLoader {
                        // Mark this class as loaded
                        $this->loadedClasses[] = $this->classes[$fileName];
 
+                       // Remove it from classes list
+                       unset($this->classes[$fileName]);
+
                        // Developer mode excludes caching (better debugging)
                        if (!defined('DEVELOPER')) {
                                // Reset cache