Skip to content

Commit

Permalink
ModuleAutoloader to build classmap array as it discovers Module classes
Browse files Browse the repository at this point in the history
Rationale is that we can use this array to build a classmap cache which can be
used to bypass the scanning process for subsequent requests.
  • Loading branch information
EvanDotPro committed Oct 29, 2011
1 parent 6bafc23 commit f310591
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ModuleAutoloader.php
Expand Up @@ -34,6 +34,11 @@ class ModuleAutoloader implements SplAutoloader
'zip',
);

/**
* @var array An array of module classes to their containing files
*/
protected $moduleClassMap = array();

/**
* Constructor
*
Expand Down Expand Up @@ -124,6 +129,7 @@ protected function loadModuleFromDir($dirPath, $class)
// Found directory with Module.php in it
require_once $file->getRealPath();
if (class_exists($class)) {
$this->moduleClassMap[$class] = $file->getRealPath();
return $class;
}
}
Expand Down Expand Up @@ -151,6 +157,7 @@ protected function loadModuleFromPhar($pharPath, $class)
// First see if the stub makes the Module class available
require_once $file->getRealPath();
if (class_exists($class)) {
$this->moduleClassMap[$class] = $file->getRealPath();
return $class;
}
}
Expand All @@ -160,6 +167,7 @@ protected function loadModuleFromPhar($pharPath, $class)
if ($moduleFile->isReadable() && $moduleFile->isFile()) {
require_once $moduleClassFile;
if (class_exists($class)) {
$this->moduleClassMap[$class] = $moduleClassFile;
return $class;
}
}
Expand All @@ -172,6 +180,7 @@ protected function loadModuleFromPhar($pharPath, $class)
if ($moduleFile->isReadable() && $moduleFile->isFile()) {
require_once $moduleClassFile;
if (class_exists($class)) {
$this->moduleClassMap[$class] = $moduleClassFile;
return $class;
}
}
Expand Down

0 comments on commit f310591

Please sign in to comment.