All empty double-quoted strings replaced with single-quotes
[core.git] / inc / loader / class_ClassLoader.php
index aa592e1127b8744c9c66002e7a9ff6db85229eb3..7b551d8747c95ab9f3acea3b2040a8ea150c8155 100644 (file)
@@ -25,6 +25,7 @@
  * 1.3
  *  - Constructor is now empty and factory method 'createClassLoader' is created
  *  - renamed loadClasses to scanClassPath
+ *  - Added initLoader(), $configInstance renamed to $configInstance
  * 1.2
  *  - ClassLoader rewritten to PHP SPL's own RecursiveIteratorIterator class
  * 1.1
@@ -39,11 +40,6 @@ class ClassLoader {
         */
        private static $selfInstance = null;
 
-       /**
-        * Configuration array
-        */
-       private $cfg = array();
-
        /**
         * Array with all classes
         */
@@ -88,12 +84,12 @@ class ClassLoader {
        /**
         * Filename for the list cache
         */
-       private $listCacheFQFN = "";
+       private $listCacheFQFN = '';
 
        /**
         * Cache for class content
         */
-       private $classCacheFQFN = "";
+       private $classCacheFQFN = '';
 
        /**
         * Counter for loaded include files
@@ -113,22 +109,39 @@ class ClassLoader {
        /**
         * Our renamed factory method
         *
-        * @param       $cfgInstance    Configuration class instance
+        * @param       $configInstance Configuration class instance
+        * @return      void
+        */
+       public final static function createClassLoader (FrameworkConfiguration $configInstance) {
+               // Get a new instance
+               $loaderInstance = new ClassLoader();
+
+               // Init the instance
+               $loaderInstance->initLoader($configInstance);
+
+               // Return the prepared instance
+               return $loaderInstance;
+       }
+
+       /**
+        * Initializes our loader class
+        *
+        * @param       $configInstance Configuration class instance
         * @return      void
         */
-       public final static function createClassLoader (FrameworkConfiguration $cfgInstance) {
+       protected function initLoader (FrameworkConfiguration $configInstance) {
                // Set configuration instance
-               $this->cfgInstance = $cfgInstance;
+               $this->configInstance = $configInstance;
 
                // Construct the FQFN for the cache
                if (!defined('DEVELOPER')) {
-                       $this->listCacheFQFN  = $this->cfgInstance->readConfig('local_db_path') . "list-" . $this->cfgInstance->readConfig('app_name') . ".cache";
-                       $this->classCacheFQFN = $this->cfgInstance->readConfig('local_db_path') . "class-" . $this->cfgInstance->readConfig('app_name') . ".cache";
+                       $this->listCacheFQFN  = $this->configInstance->readConfig('local_db_path') . "list-" . $this->configInstance->readConfig('app_name') . ".cache";
+                       $this->classCacheFQFN = $this->configInstance->readConfig('local_db_path') . "class-" . $this->configInstance->readConfig('app_name') . ".cache";
                } // END - if
 
                // Set suffix and prefix from configuration
-               $this->suffix = $cfgInstance->readConfig('class_suffix');
-               $this->prefix = $cfgInstance->readConfig('class_prefix');
+               $this->suffix = $configInstance->readConfig('class_suffix');
+               $this->prefix = $configInstance->readConfig('class_prefix');
 
                // Set own instance
                self::$selfInstance = $this;
@@ -204,7 +217,7 @@ class ClassLoader {
                // Skip here if already cached
                if ($this->classesCached === false) {
                        // Generate a full-cache of all classes
-                       $cacheContent = "";
+                       $cacheContent = '';
                        foreach ($this->loadedClasses as $fqfn) {
                                // Load the file
                                $cacheContent .= file_get_contents($fqfn);
@@ -302,7 +315,7 @@ class ClassLoader {
                $this->prefix = "config-";
 
                // Set base directory
-               $basePath = sprintf("%sinc/config/", $this->cfgInstance->readConfig('base_path'));
+               $basePath = sprintf("%sinc/config/", $this->configInstance->readConfig('base_path'));
 
                // Load all classes from the config directory
                $this->scanClassPath($basePath);
@@ -385,7 +398,7 @@ class ClassLoader {
         */
        public function getPrintableIncludeList () {
                // Prepare the list
-               $includeList = "";
+               $includeList = '';
                foreach ($this->loadedClasses as $classFile) {
                        $includeList .= basename($classFile)."<br />\n";
                } // END - foreach