]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix loading multiple version backends from one app 15869/head
authorRobin Appelman <robin@icewind.nl>
Tue, 4 Jun 2019 12:11:24 +0000 (14:11 +0200)
committerRobin Appelman <robin@icewind.nl>
Tue, 4 Jun 2019 12:11:24 +0000 (14:11 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_versions/lib/AppInfo/Application.php

index 45dc6da6e2c6c62bec56c1a2419db8ab1757ab61..6a8e50dba93052a6899b8109f12c07b38c43bd6c 100644 (file)
@@ -65,25 +65,36 @@ class Application extends App {
 
        public function registerVersionBackends() {
                $server = $this->getContainer()->getServer();
-               $logger = $server->getLogger();
                $appManager = $server->getAppManager();
-               /** @var IVersionManager $versionManager */
-               $versionManager = $this->getContainer()->getServer()->query(IVersionManager::class);
                foreach($appManager->getInstalledApps() as $app) {
                        $appInfo = $appManager->getAppInfo($app);
                        if (isset($appInfo['versions'])) {
                                $backends = $appInfo['versions'];
                                foreach($backends as $backend) {
-                                       $class = $backend['@value'];
-                                       $for = $backend['@attributes']['for'];
-                                       try {
-                                               $backendObject = $server->query($class);
-                                               $versionManager->registerBackend($for, $backendObject);
-                                       } catch (\Exception $e) {
-                                               $logger->logException($e);
+                                       if (isset($backend['@value'])) {
+                                               $this->loadBackend($backend);
+                                       } else {
+                                               foreach ($backend as $singleBackend) {
+                                                       $this->loadBackend($singleBackend);
+                                               }
                                        }
                                }
                        }
                }
        }
+
+       private function loadBackend(array $backend) {
+               $server = $this->getContainer()->getServer();
+               $logger = $server->getLogger();
+               /** @var IVersionManager $versionManager */
+               $versionManager = $this->getContainer()->getServer()->query(IVersionManager::class);
+               $class = $backend['@value'];
+               $for = $backend['@attributes']['for'];
+               try {
+                       $backendObject = $server->query($class);
+                       $versionManager->registerBackend($for, $backendObject);
+               } catch (\Exception $e) {
+                       $logger->logException($e);
+               }
+       }
 }