Added new interfaces Handleable/-DataSet and ProtocolHandler (no content yet).
[core.git] / inc / loader / class_ClassLoader.php
index dce3df9c9fa5832bf258906ccb83531146c5565f..53ee90c3d1045ffd9e8d1aea18d5719e880e4032 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -98,6 +98,17 @@ class ClassLoader {
         */
        private $total = 0;
 
+       /**
+        * Framework/application paths for classes, etc.
+        */
+       private static $frameworkPaths = array(
+               'exceptions', // Exceptions
+               'interfaces', // Interfaces
+               'main',       // General main classes
+               'middleware'  // The middleware
+       );
+
+
        /**
         * The protected constructor. Please use the factory method below, or use
         * getSelfInstance() for singleton
@@ -163,24 +174,38 @@ class ClassLoader {
         * @return      void
         */
        public static function scanFrameworkClasses () {
-               // Lower framework classes
-               $lowerClasses = array(
-                       'exceptions', // Exceptions
-                       'interfaces', // Interfaces
-                       'main',       // General main classes
-                       'middleware'  // The middleware
-               );
-
                // Cache loader instance
                $loaderInstance = self::getSelfInstance();
 
                // Load all classes
-               foreach ($lowerClasses as $className) {
+               foreach (self::$frameworkPaths as $className) {
                        // Try to load the framework classes
                        $loaderInstance->scanClassPath('inc/classes/' . $className . '/');
                } // END - foreach
        }
 
+       /**
+        * Scans for application's classes, etc.
+        *
+        * @return      void
+        */
+       public static function scanApplicationClasses () {
+               // Get config instance
+               $cfg = FrameworkConfiguration::getSelfInstance();
+
+               // Load all classes for the application
+               foreach (self::$frameworkPaths as $class) {
+                       // Create path name
+                       $path = sprintf('%s/%s/%s', $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $class);
+
+                       // Is the path readable?
+                       if (is_dir($path)) {
+                               // Try to load the application classes
+                               ClassLoader::getSelfInstance()->scanClassPath($path);
+                       } // END - if
+               } // END - foreach
+       }
+
        /**
         * Initializes our loader class
         *
@@ -280,7 +305,6 @@ class ClassLoader {
                array_push($ignoreList, '.');
                array_push($ignoreList, '..');
                array_push($ignoreList, '.htaccess');
-               array_push($ignoreList, '.svn');
 
                // Keep it in class for later usage
                $this->ignoreList = $ignoreList;
@@ -295,7 +319,7 @@ class ClassLoader {
                // If the basePath is FALSE it is invalid
                if ($basePath2 === FALSE) {
                        /* @todo: Do not die here. */
-                       exit(__METHOD__ . ':Cannot read ' . $basePath . ' !');
+                       exit(__METHOD__ . ':Cannot read ' . $basePath . ' !' . PHP_EOL);
                } else {
                        // Set base path
                        $basePath = $basePath2;