aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/App
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-02-08 12:35:57 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-03-20 10:21:45 +0100
commit78c17168185c21b6b788e40602f95c690fe441f9 (patch)
treeef53bbc85e48499a0e3e949f581b0e6e0c5b9565 /lib/private/App
parent8dc5f8218979a8bf05ac5a8e84649f750dcab5ec (diff)
downloadnextcloud-server-78c17168185c21b6b788e40602f95c690fe441f9.tar.gz
nextcloud-server-78c17168185c21b6b788e40602f95c690fe441f9.zip
Move loadApps to the AppManager
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/App')
-rw-r--r--lib/private/App/AppManager.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index 59df44cbd17..d969f1d0260 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -179,6 +179,55 @@ class AppManager implements IAppManager {
}
/**
+ * Loads all apps
+ *
+ * @param string[] $types
+ * @return bool
+ *
+ * This function walks through the Nextcloud directory and loads all apps
+ * it can find. A directory contains an app if the file /appinfo/info.xml
+ * exists.
+ *
+ * if $types is set to non-empty array, only apps of those types will be loaded
+ */
+ public function loadApps(array $types = []): bool {
+ if ($this->config->getSystemValueBool('maintenance', false)) {
+ return false;
+ }
+ // Load the enabled apps here
+ $apps = \OC_App::getEnabledApps();
+
+ // Add each apps' folder as allowed class path
+ foreach ($apps as $app) {
+ // If the app is already loaded then autoloading it makes no sense
+ if (!$this->isAppLoaded($app)) {
+ $path = \OC_App::getAppPath($app);
+ if ($path !== false) {
+ \OC_App::registerAutoloading($app, $path);
+ }
+ }
+ }
+
+ // prevent app.php from printing output
+ ob_start();
+ foreach ($apps as $app) {
+ if (!$this->isAppLoaded($app) && ($types === [] || $this->isType($app, $types))) {
+ try {
+ $this->loadApp($app);
+ } catch (\Throwable $e) {
+ $this->logger->emergency('Error during app loading: ' . $e->getMessage(), [
+ 'exception' => $e,
+ 'app' => $app,
+ ]);
+ }
+ }
+ }
+ ob_end_clean();
+
+ return true;
+ }
+
+ /**
* check if an app is of a specific type
*
* @param string $app