public function loadClass($className)
{
$origClassName = str_replace('-', '', $className);
/**/
$this->app->pr->start('pathfinder/loadClass ');
/**/
$this->app->pr->next('pathfinder/loadClass/convertpath ');
$className = ltrim($className, '\\');
$nsPath = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$nsPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
}
$classPath = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
/**/
$this->app->pr->next('pathfinder/loadClass/locate ');
try {
if ($namespace) {
if (strpos($className, 'page_') === 0) {
$path = $this->app->locatePath('addons', $nsPath . DIRECTORY_SEPARATOR . $classPath);
} else {
$path = $this->app->locatePath('addons', $nsPath . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $classPath);
}
} else {
if (strpos($className, 'page_') === 0) {
$path = $this->app->locatePath('page', substr($classPath, 5));
} else {
$path = $this->app->locatePath('php', $classPath);
}
}
} catch (Exception_PathFinder $e) {
$e->addMoreInfo('class', $className)->addMoreInfo('namespace', $namespace)->addMoreInfo('orig_class', $origClassName);
throw $e;
}
if (!is_readable($path)) {
throw new Exception_PathFinder('addon', $path, $prefix);
}
/**/
$this->app->pr->next('pathfinder/loadClass/include ');
/**/
$this->app->pr->start('php parsing');
include_once $path;
/**/
$this->app->pr->stop();
if (!class_exists($origClassName, false) && !interface_exists($origClassName, false)) {
throw $this->exception('Class is not defined in file')->addMoreInfo('file', $path)->addMoreInfo('namespace', $namespace)->addMoreInfo('class', $className);
}
/**/
$this->app->pr->stop();
return $path;
}