Passed
Push — master ( e76c17...4a4262 )
by Roeland
13:37 queued 11s
created

Application::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright (c) 2019 Joas Schilling <[email protected]>
7
 *
8
 * @author Christoph Wurst <[email protected]>
9
 * @author Joas Schilling <[email protected]>
10
 * @author Roeland Jago Douma <[email protected]>
11
 *
12
 * @license GNU AGPL version 3 or any later version
13
 *
14
 * This program is free software: you can redistribute it and/or modify
15
 * it under the terms of the GNU Affero General Public License as
16
 * published by the Free Software Foundation, either version 3 of the
17
 * License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU Affero General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU Affero General Public License
25
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26
 *
27
 */
28
29
namespace OCA\LookupServerConnector\AppInfo;
30
31
use OCA\LookupServerConnector\UpdateLookupServer;
32
use OCP\AppFramework\App;
33
use OCP\AppFramework\Bootstrap\IBootContext;
34
use OCP\AppFramework\Bootstrap\IBootstrap;
35
use OCP\AppFramework\Bootstrap\IRegistrationContext;
36
use OCP\IUser;
37
use Symfony\Component\EventDispatcher\GenericEvent;
38
39
class Application extends App implements IBootstrap {
40
	public const APP_ID = 'lookup_server_connector';
41
42
	public function __construct() {
43
		parent::__construct(self::APP_ID);
44
	}
45
46
	public function register(IRegistrationContext $context): void {
47
	}
48
49
	public function boot(IBootContext $context): void {
50
		/*
51
		 * @todo move the OCP events and then move the registration to `register`
52
		 */
53
		$dispatcher = $context->getServerContainer()->getEventDispatcher();
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IServerContainer::getEventDispatcher() has been deprecated: 20.0.0 use \OCP\EventDispatcher\IEventDispatcher ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

53
		$dispatcher = /** @scrutinizer ignore-deprecated */ $context->getServerContainer()->getEventDispatcher();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
54
		$dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) use ($context) {
55
			/** @var IUser $user */
56
			$user = $event->getSubject();
57
58
			/** @var UpdateLookupServer $updateLookupServer */
59
			$updateLookupServer = $context->getServerContainer()->query(UpdateLookupServer::class);
60
			$updateLookupServer->userUpdated($user);
61
		});
62
	}
63
}
64