Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
delay sending event from app init to when they are needed
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Aug 2, 2019
commit 792903e6b3e760588caa7b2311265cb9b275597b
6 changes: 0 additions & 6 deletions apps/files_external/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ public function __construct(array $urlParams = []) {
// 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'
);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions apps/files_external/lib/Service/BackendService.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,18 @@ public function registerBackendProvider(IBackendProvider $provider) {
$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());
}
Expand All @@ -124,6 +135,7 @@ public function registerAuthMechanismProvider(IAuthMechanismProvider $provider)
}

private function loadAuthMechanismProviders() {
$this->callForRegistrations();
foreach ($this->authMechanismProviders as $provider) {
$this->registerAuthMechanisms($provider->getAuthMechanisms());
}
Expand Down Expand Up @@ -321,6 +333,7 @@ public function registerConfigHandler(string $placeholder, callable $configHandl
}

protected function loadConfigHandlers():void {
$this->callForRegistrations();
$newLoaded = false;
foreach ($this->configHandlerLoaders as $placeholder => $loader) {
$handler = $loader();
Expand Down