/** * Finds the path to the file, that contains the specified class. * * @param string $class The fully-qualified class name * * @return string|false The path if found, false otherwise */ public function findFile($class) { $class = Normalizer::ns($class, false); if (isset($this->classMap[$class])) { return $this->classMap[$class]; } $index = substr($class, 0, 4); if (isset($this->indexes[$index])) { $namespace = $class; while (false !== ($pos = strrpos($namespace, '\\'))) { $namespace = substr($class, 0, $pos + 1); if (!isset($this->paths[$namespace])) { $namespace = rtrim($namespace, '\\'); continue; } $subclass = substr($class, $pos + 1); $subpath = Normalizer::path($subclass, false) . '.php'; foreach ($this->paths[$namespace] as $dir) { $path = $dir . $subpath; if (is_readable($path)) { if ($this->classRegistration) { $this->classMap[$class] = $path; } return $path; } } $namespace = rtrim($namespace, '\\'); } } if ($this->classRegistration) { $this->classMap[$class] = false; } return false; }
/** * Finds the path to the file where the Module class is defined. * * @param string $class The name of the Module class * * @return string|false The path if found, false otherwise */ public function findFile($class) { if (substr($class, -7) !== '\\Module') { return false; } $path = Normalizer::path($class, false) . '.php'; foreach ($this->paths as $dir) { $file = $dir . $path; if (is_readable($file)) { return $file; } } return false; }