diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-05-03 08:24:22 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-05-03 08:24:22 +0200 |
commit | a72e6a2dac82c90582d478ead1f5518fc7299f80 (patch) | |
tree | 233970891ace12f1fadb99456d4c5a7259b6a23a /lib/private/legacy/app.php | |
parent | 1974ae8da7dd23f2abfc70ae84b6c8a349fe94ae (diff) | |
parent | d879354ccb19278a45fc28ac9fcf12ec4c0876ea (diff) | |
download | nextcloud-server-a72e6a2dac82c90582d478ead1f5518fc7299f80.tar.gz nextcloud-server-a72e6a2dac82c90582d478ead1f5518fc7299f80.zip |
Merge pull request #24386 from owncloud/psr4-for-apps
PSR-4 for apps
Diffstat (limited to 'lib/private/legacy/app.php')
-rw-r--r-- | lib/private/legacy/app.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 41b1b79e4f6..fe590e4159e 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -108,7 +108,7 @@ class OC_App { foreach($apps as $app) { $path = self::getAppPath($app); if($path !== false) { - \OC::$loader->addValidRoot($path); + self::registerAutoloading($app, $path); } } @@ -137,7 +137,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)) { @@ -156,6 +159,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 . '/lib/', 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 * * @param string $app app name |