summaryrefslogtreecommitdiffstats
path: root/lib/private/legacy/app.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-10-17 11:49:32 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-10-17 21:35:49 +0200
commit3a9c24c04f41c845df45a8208e6ea1c007487122 (patch)
tree0777aa23beeaa5a6e2dcbb277cc1630d665b6c8f /lib/private/legacy/app.php
parentcd0d27e46dd2dbe649108e82c9c61254b1ff9f39 (diff)
downloadnextcloud-server-3a9c24c04f41c845df45a8208e6ea1c007487122.tar.gz
nextcloud-server-3a9c24c04f41c845df45a8208e6ea1c007487122.zip
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>
Diffstat (limited to 'lib/private/legacy/app.php')
-rw-r--r--lib/private/legacy/app.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 627107a63a8..bd261b05e51 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -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);
}
/**