Skip to content

Commit

Permalink
move logic from contstructor to boot method
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Mar 26, 2021
1 parent 369e9f5 commit 622ba4f
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions apps/files_external/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
use OCP\User\Events\UserDeletedEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use function foo\func;

require_once __DIR__ . '/../../3rdparty/autoload.php';

Expand All @@ -91,20 +92,6 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
*/
public function __construct(array $urlParams = []) {
parent::__construct('files_external', $urlParams);

$container = $this->getContainer();

/** @var BackendService $backendService */
$backendService = $container->query(BackendService::class);
$backendService->registerBackendProvider($this);
$backendService->registerAuthMechanismProvider($this);
$backendService->registerConfigHandler('user', function () use ($container) {
return $container->query(UserPlaceholderHandler::class);
});

// 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();
}

public function register(IRegistrationContext $context): void {
Expand All @@ -126,7 +113,17 @@ public function boot(IBootContext $context): void {
'name' => $l->t('External storages'),
];
});
$context->injectFn([$this, 'registerListeners']);
$context->injectFn(function(BackendService $backendService, UserPlaceholderHandler $userConfigHandler) {
$backendService->registerBackendProvider($this);
$backendService->registerAuthMechanismProvider($this);
$backendService->registerConfigHandler('user', function () use ($userConfigHandler) {
return $userConfigHandler;
});
});

// 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();
}

/**
Expand Down

0 comments on commit 622ba4f

Please sign in to comment.