You are here

class xautoload_ClassFinder in X Autoload 6

Same name and namespace in other branches
  1. 7 lib/ClassFinder.php \xautoload_ClassFinder

We don't put this in the lib folder, obviously, because it has to be available before xautoload is initialized.

The thing is called ClassFinder, but it also works for interfaces.

Hierarchy

Expanded class hierarchy of xautoload_ClassFinder

File

./xautoload.module, line 45

View source
class xautoload_ClassFinder {
  protected $modules = array();
  function __construct($modules) {
    $this->modules = $modules;
  }
  function findFile($class) {
    if (preg_match('/^([a-z0-9_]+)_([A-Z].*)$/', $class, $m)) {
      list(, $module, $name) = $m;
      if (isset($this->modules[$module])) {
        $path = strtr($name, '_', '/');
        $path = $this->modules[$module] . $path . '.inc';
        if (file_exists($path)) {
          return $path;
        }
      }
    }
  }

}

Members