private static $selfInstance = NULL;
/**
- * Array with all classes
+ * Array with all found classes
*/
- private $classes = array();
+ private $foundClasses = array();
/**
* List of loaded classes
// Skip here if already cached
if ($this->listCached === FALSE) {
// Writes the cache file of our list away
- $cacheContent = json_encode($this->classes);
+ $cacheContent = json_encode($this->foundClasses);
file_put_contents($this->listCacheFQFN, $cacheContent);
} // END - if
if ($this->classesCached === FALSE) {
// Generate a full-cache of all classes
$cacheContent = '';
- foreach ($this->loadedClasses as $fqfn) {
+ foreach (array_keys($this->loadedClasses) as $fqfn) {
// Load the file
$cacheContent .= file_get_contents($fqfn);
} // END - foreach
$cacheContent = file_get_contents($this->listCacheFQFN);
// And convert it
- $this->classes = json_decode($cacheContent);
+ $this->foundClasses = json_decode($cacheContent);
// List has been restored from cache!
$this->listCached = TRUE;
if ((substr($fileName, 0, strlen($this->prefix)) == $this->prefix) && (substr($fileName, -strlen($this->suffix), strlen($this->suffix)) == $this->suffix)) {
// Add it to the list
/* NOISY-DEBUG: */ printf('[%s:%d] ADD: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
- $this->classes[$fileName] = $fqfn;
+ $this->foundClasses[$fileName] = $fqfn;
} else {
// Not added
/* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
// Now look it up in our index
/* NOISY-DEBUG: */ printf('[%s:%d] ISSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
- if ((isset($this->classes[$fileName])) && (!in_array($this->classes[$fileName], $this->loadedClasses))) {
+ if ((isset($this->foundClasses[$fileName])) && (!isset($this->loadedClasses[$this->foundClasses[$fileName]]))) {
// File is found and not loaded so load it only once
/* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
- require($this->classes[$fileName]);
+ require($this->foundClasses[$fileName]);
/* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName);
// Count this loaded class/interface/exception
$this->total++;
// Mark this class as loaded for other purposes than loading it.
- array_push($this->loadedClasses, $this->classes[$fileName]);
+ $this->loadedClasses[$this->foundClasses[$fileName]] = TRUE;
// Remove it from classes list so it won't be found twice.
/* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
- unset($this->classes[$fileName]);
+ unset($this->foundClasses[$fileName]);
// Developer mode excludes caching (better debugging)
if (!defined('DEVELOPER')) {
*/
private function includeExtraConfigs () {
// Run through all class names (should not be much)
- foreach ($this->classes as $fileName => $fqfn) {
+ foreach ($this->foundClasses as $fileName => $fqfn) {
// Is this a config?
if (substr($fileName, 0, strlen($this->prefix)) == $this->prefix) {
// Then include it
+ /* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
require($fqfn);
+ /* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName);
// Remove it from the list
/* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
- unset($this->classes[$fileName]);
+ unset($this->foundClasses[$fileName]);
} // END - if
} // END - foreach
}