Register the PSR-4 path on loadApp

This commit is contained in:
Joas Schilling 2016-05-02 14:11:34 +02:00
parent 8668560352
commit ee3457aec0
No known key found for this signature in database
GPG key ID: 70A0B324C41C0946

View file

@ -107,7 +107,7 @@ class OC_App {
foreach($apps as $app) {
$path = self::getAppPath($app);
if($path !== false) {
\OC::$loader->addValidRoot($path);
self::registerAutoloading($app, $path);
}
}
@ -136,7 +136,10 @@ class OC_App {
if($appPath === false) {
return;
}
\OC::$loader->addValidRoot($appPath); // in case someone calls loadApp() directly
// in case someone calls loadApp() directly
self::registerAutoloading($app, $appPath);
if (is_file($appPath . '/appinfo/app.php')) {
\OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
if ($checkUpgrade and self::shouldUpgrade($app)) {
@ -154,6 +157,22 @@ class OC_App {
}
}
/**
* @param string $app
* @param string $path
*/
protected static function registerAutoloading($app, $path) {
// Register on PSR-4 composer autoloader
$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/src/', true);
if (defined('PHPUNIT_RUN')) {
\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
}
// Register on legacy autoloader
\OC::$loader->addValidRoot($path);
}
/**
* Load app.php from the given app
*