diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-07-13 15:43:42 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-07-23 08:33:17 +0200 |
commit | 0763a173321488acaadceb1eb0ecf1ec8691bf21 (patch) | |
tree | e3a722bae6695c6ce2e0feaf06298effcf92d773 /apps/federation/lib/AppInfo | |
parent | 99d0ba5f7ea45bb636cfcfc2de144e25af88b916 (diff) | |
download | nextcloud-server-0763a173321488acaadceb1eb0ecf1ec8691bf21.tar.gz nextcloud-server-0763a173321488acaadceb1eb0ecf1ec8691bf21.zip |
Move federated_share_added into a typed event
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/federation/lib/AppInfo')
-rw-r--r-- | apps/federation/lib/AppInfo/Application.php | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/apps/federation/lib/AppInfo/Application.php b/apps/federation/lib/AppInfo/Application.php index 09a6eed4abe..36a61298c90 100644 --- a/apps/federation/lib/AppInfo/Application.php +++ b/apps/federation/lib/AppInfo/Application.php @@ -27,58 +27,32 @@ namespace OCA\Federation\AppInfo; -use OCA\Federation\DAV\FedAuth; -use OCA\Federation\Hooks; +use OCA\DAV\Events\SabrePluginAuthInitEvent; +use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent; +use OCA\Federation\Listener\FederatedShareAddedListener; +use OCA\Federation\Listener\SabrePluginAuthInitListener; use OCA\Federation\Middleware\AddServerMiddleware; use OCP\AppFramework\App; -use OCP\SabrePluginEvent; -use OCP\Share; -use OCP\Util; -use Sabre\DAV\Auth\Plugin; -use Sabre\DAV\Server; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; -class Application extends App { +class Application extends App implements IBootstrap { /** * @param array $urlParams */ public function __construct($urlParams = []) { parent::__construct('federation', $urlParams); - $this->registerMiddleware(); } - private function registerMiddleware() { - $container = $this->getContainer(); - $container->registerAlias('AddServerMiddleware', AddServerMiddleware::class); - $container->registerMiddleWare('AddServerMiddleware'); - } + public function register(IRegistrationContext $context): void { + $context->registerMiddleware(AddServerMiddleware::class); - /** - * listen to federated_share_added hooks to auto-add new servers to the - * list of trusted servers. - */ - public function registerHooks() { - $container = $this->getContainer(); - $hooksManager = $container->query(Hooks::class); - - Util::connectHook( - Share::class, - 'federated_share_added', - $hooksManager, - 'addServerHook' - ); + $context->registerEventListener(FederatedShareAddedEvent::class, FederatedShareAddedListener::class); + $context->registerEventListener(SabrePluginAuthInitEvent::class, SabrePluginAuthInitListener::class); + } - $dispatcher = $container->getServer()->getEventDispatcher(); - $dispatcher->addListener('OCA\DAV\Connector\Sabre::authInit', function ($event) use ($container) { - if ($event instanceof SabrePluginEvent) { - $server = $event->getServer(); - if ($server instanceof Server) { - $authPlugin = $server->getPlugin('auth'); - if ($authPlugin instanceof Plugin) { - $authPlugin->addBackend($container->query(FedAuth::class)); - } - } - } - }); + public function boot(IBootContext $context): void { } } |