aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib/AppInfo/Application.php
blob: fda75c475b69f4ca1470c50fa9e7d6308409c507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

/**
 * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
 * SPDX-License-Identifier: AGPL-3.0-only
 */
namespace OCA\FederatedFileSharing\AppInfo;

use Closure;
use OCA\FederatedFileSharing\Listeners\LoadAdditionalScriptsListener;
use OCA\FederatedFileSharing\Notifier;
use OCA\FederatedFileSharing\OCM\CloudFederationProviderFiles;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\IAppContainer;
use OCP\Federation\ICloudFederationProviderManager;

class Application extends App implements IBootstrap {
	public function __construct() {
		parent::__construct('federatedfilesharing');
	}

	public function register(IRegistrationContext $context): void {
		$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScriptsListener::class);
		$context->registerNotifierService(Notifier::class);
	}

	public function boot(IBootContext $context): void {
		$context->injectFn(Closure::fromCallable([$this, 'registerCloudFederationProvider']));
	}

	private function registerCloudFederationProvider(ICloudFederationProviderManager $manager,
		IAppContainer $appContainer): void {
		$manager->addCloudFederationProvider('file',
			'Federated Files Sharing',
			function () use ($appContainer): CloudFederationProviderFiles {
				return $appContainer->get(CloudFederationProviderFiles::class);
			});
	}
}