+ * 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
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Is currently empty
+ }
+
+ /**
+ * The destructor makes it sure all caches got flushed
+ *
+ * @return void
+ */
+ public function __destruct () {
+ // Skip here if dev-mode
+ if (defined('DEVELOPER')) {
+ return;
+ } // END - if
+
+ // Skip here if already cached
+ if ($this->listCached === FALSE) {
+ // Writes the cache file of our list away
+ $cacheContent = serialize($this->classes);
+ file_put_contents($this->listCacheFQFN, $cacheContent);
+ } // END - if
+
+ // Skip here if already cached
+ if ($this->classesCached === FALSE) {
+ // Generate a full-cache of all classes
+ $cacheContent = '';
+ foreach ($this->loadedClasses as $fqfn) {
+ // Load the file
+ $cacheContent .= file_get_contents($fqfn);
+ } // END - foreach
+
+ // And write it away
+ file_put_contents($this->classCacheFQFN, $cacheContent);
+ } // END - if
+ }
+
+ /**
+ * Creates an instance of this class loader for given configuration instance
+ *
+ * @param $configInstance Configuration class instance
+ * @return void
+ */
+ public static final function createClassLoader (FrameworkConfiguration $configInstance) {
+ // Get a new instance
+ $loaderInstance = new ClassLoader();
+
+ // Init the instance
+ $loaderInstance->initLoader($configInstance);
+
+ // Return the prepared instance
+ return $loaderInstance;
+ }
+
+ /**
+ * Scans for all framework classes, exceptions and interfaces.
+ *
+ * @return void
+ */
+ public static function scanFrameworkClasses () {
+ // Cache loader instance
+ $loaderInstance = self::getSelfInstance();
+
+ // Load all classes
+ foreach (self::$frameworkPaths as $className) {
+ // Try to load the framework classes
+ $loaderInstance->scanClassPath('inc/classes/' . $className . '/');
+ } // END - foreach
+ }
+
+ /**
+ * Scans for application's classes, etc.