- // Load all super classes (backward, why ever this name... :-? )
- // We don't support sub directories here...
- $this->scanLocalPath($basePath);
-
- // While there are directories in our list scan them for classes
- $cnt = 0;
- while ($cnt != $this->dirList->count()) {
- for ($idx = $this->dirList->getIterator(); $idx->valid(); $idx->next()) {
- // Get current path
- $currPath = $idx->current();
-
- // Remove the current entry or else this will lead into a infinite loop
- $this->dirList->offsetSet($idx->key(), "");
-
- // Scan the directory
- $this->scanLocalPath($currPath);
- }
-
- // Check if we can leave
- $cnt = 0;
- for ($idx = $this->dirList->getIterator(); $idx->valid(); $idx->next()) {
- if ($idx->current() == "") $cnt++;
- }
- }
- }
-
- /**
- * The local path scanner. A found class will be loaded immediately
- * @param $localPath The local path which shall be recursively scanned for include files
- * @return void
- */
- private function scanLocalPath ($localPath) {
- // Empty path names will be silently ignored
- if (empty($localPath)) return;
-
- // TODO: No dies here, mayybe this should be rewritten to throw an exception?
- $dirInstance = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($localPath);
- while ($dirClass = $dirInstance->readDirectoryExcept($this->ignoreList)) {
- // We need the relative dir name as an array index some lines below
- $dirClass2 = $dirClass;
-
- // A nice replacement for a simple dot ;)
- $dirClass = sprintf("%s/%s", $localPath, $dirClass);
-
- // Is a readable file with configured prefix and suffix? All other
- // files will silently be ignored!
- //* DEBUG: */ print "Prefix=".$this->prefix."(".substr($dirClass2, 0 , $this->preLen).")\n";
- //* DEBUG: */ print "Suffix=".$this->suffix."(".substr($dirClass2, -$this->sufLen, $this->sufLen).")\n";
- //* DEBUG: */ print "ENTRY={$dirClass}\n";
- if (
- (is_file($dirClass))
- && (is_readable($dirClass))
- && (substr($dirClass2, 0 , $this->preLen) == $this->prefix)
- && (substr($dirClass2, -$this->sufLen, $this->sufLen) == $this->suffix)
- ) {
- // Class found so load it instantly
- //* DEBUG: */ print "CLASS={$dirClass}\n";
- $this->classes->append($dirClass);
- $this->classCnt++;
- } elseif (is_dir($dirClass) && !in_array($dirClass2, $this->ignoreList)) {
- // Directory found and added to list
- //* DEBUG: */ print "DIR={$dirClass}\n";
- if ($dirClass2 == "interfaces") {
- $this->scanLocalPath($dirClass);
- } else {
- $this->dirList->append($dirClass);
- }
- $this->dirCnt++;
- }
- //* DEBUG: */ print "LOOP!\n";
- } // END - while
-
- // Close directory handler
- $dirInstance->closeDirectory();
-
- // Output counter in debug mode
- if (defined('DEBUG_MODE')) print(sprintf("[%s:] <strong>%d</strong> Klassendateien in <strong>%d</strong> Verzeichnissen gefunden und geladen.<br />\n",
- __CLASS__,
- $this->classCnt,
- $this->dirCnt
- ));
- }
-
- /**
- * Includes all found classes
- * @return void
- */
- public function includeAllClasses () {
- if (is_object($this->classes)) {
- // Load all classes
- for ($idx = $this->classes->getIterator(); $idx->valid(); $idx->next()) {
- // Load current class
- //* DEBUG: */ print "Class=".$idx->current()."\n";
- require_once($idx->current());
- }
-
- // Re-initialize the classes list
- $this->classes = new ArrayObject();
- }
+ // Get a new iterator
+ //* DEBUG: */ echo "<strong>Base path: {$basePath}</strong><br />\n";
+ $iterator = new RecursiveDirectoryIterator($basePath);
+ $recursive = new RecursiveIteratorIterator($iterator);
+ foreach ($recursive as $entry) {
+ // Get filename from iterator
+ $fileName = $entry->getFileName();
+
+ // Is this file wanted?
+ //* DEBUG: */ echo "FOUND:{$fileName}<br />\n";
+ if ((!in_array($fileName, $this->ignoreList)) && (substr($fileName, 0, $this->prefixLen) == $this->prefix) && (substr($fileName, -$this->suffixLen, $this->suffixLen) == $this->suffix)) {
+ // Get the FQFN and add it to our class list
+ $fqfn = $entry->getRealPath();
+ //* DEBUG: */ echo "ADD: {$fileName}<br />\n";
+ $this->classes[$fileName] = $fqfn;
+ } // END - if
+ } // END - foreach