]> source.dussan.org Git - nextcloud-server.git/commitdiff
delay sending event from app init to when they are needed 16638/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Fri, 2 Aug 2019 11:17:55 +0000 (13:17 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Fri, 2 Aug 2019 12:26:43 +0000 (14:26 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/files_external/lib/AppInfo/Application.php
apps/files_external/lib/Service/BackendService.php

index 01de6f1e40bfcda99a7dce47b33ee8ca8930a3da..7a9325414d81e0463c000e20663612e4b6b76b85 100644 (file)
@@ -93,12 +93,6 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
                // force-load auth mechanisms since some will register hooks
                // TODO: obsolete these and use the TokenProvider to get the user's password from the session
                $this->getAuthMechanisms();
-
-               // don't remove this, as app loading order might be a side effect and
-               // querying the service from the server not reliable
-               \OC::$server->getEventDispatcher()->dispatch(
-                       'OCA\\Files_External::loadAdditionalBackends'
-               );
        }
 
        /**
index bd4d2bffa7b9cb8b1ac390a85295751b13d7dfaa..59af54f79e433a2984785171b1a7497da61a5724 100644 (file)
@@ -106,7 +106,18 @@ class BackendService {
                $this->backendProviders[] = $provider;
        }
 
+       private function callForRegistrations() {
+               static $eventSent = false;
+               if(!$eventSent) {
+                       \OC::$server->getEventDispatcher()->dispatch(
+                               'OCA\\Files_External::loadAdditionalBackends'
+                       );
+                       $eventSent = true;
+               }
+       }
+
        private function loadBackendProviders() {
+               $this->callForRegistrations();
                foreach ($this->backendProviders as $provider) {
                        $this->registerBackends($provider->getBackends());
                }
@@ -124,6 +135,7 @@ class BackendService {
        }
 
        private function loadAuthMechanismProviders() {
+               $this->callForRegistrations();
                foreach ($this->authMechanismProviders as $provider) {
                        $this->registerAuthMechanisms($provider->getAuthMechanisms());
                }
@@ -321,6 +333,7 @@ class BackendService {
        }
 
        protected function loadConfigHandlers():void {
+               $this->callForRegistrations();
                $newLoaded = false;
                foreach ($this->configHandlerLoaders as $placeholder => $loader) {
                        $handler = $loader();