Allow apps to have their own autoloader
This will allow apps to also have a proper classmap and authorative autoloader. Currently if a file: <appdir>/composer/autoload.php exists we will use it. Else we keep the current behavior. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
cd0d27e46d
commit
3a9c24c04f
|
@ -200,17 +200,25 @@ class OC_App {
|
|||
if(isset(self::$alreadyRegistered[$key])) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$alreadyRegistered[$key] = true;
|
||||
|
||||
// Register on PSR-4 composer autoloader
|
||||
$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
|
||||
\OC::$server->registerNamespace($app, $appNamespace);
|
||||
\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
|
||||
|
||||
if (file_exists($path . '/composer/autoload.php')) {
|
||||
require_once $path . '/composer/autoload.php';
|
||||
} else {
|
||||
\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
|
||||
// Register on legacy autoloader
|
||||
\OC::$loader->addValidRoot($path);
|
||||
}
|
||||
|
||||
// Register Test namespace only when testing
|
||||
if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
|
||||
\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
|
||||
}
|
||||
|
||||
// Register on legacy autoloader
|
||||
\OC::$loader->addValidRoot($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue