function xautoload_DrupalExtensionSystem::getExtensionPath in X Autoload 7.2
Get the directory path for a module or theme.
Parameters
$name: Name of the module or theme.
File
- lib/
DrupalExtensionSystem.php, line 19
Class
- xautoload_DrupalExtensionSystem
- That's an abstraction of the Drupal module/theme system. It can tell us when an extension exists, and at which path.
Code
function getExtensionPath($name) {
if (isset($this->paths[$name])) {
return $this->paths[$name];
}
// Now let's check if we're still in bootstrap phase, and should switch to
// main phase.
// TODO: That's expensive, isn't it?
// TODO: What about themes? What if we want a class in a theme, before
// a module class switches this to main phase?
if (!$this->inMainPhase) {
// We want an indicator to tell us when we are done with bootstrap.
// module_exists() seems like a good candidate. If we call that with an
// existing non-bootstrap mdoule and it returns true, we know we are past
// bootstrap.
if (module_exists($name)) {
// The module_list() knows more than we do.
// Time to switch to main phase.
$this
->mainPhase();
return isset($this->paths[$name]) ? $this->paths[$name] : NULL;
}
}
}