Passed
Pull Request — master (#1603)
by René
04:14
created

Application::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
 *
5
 * @author Vinzenz Rosenkranz <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Polls\AppInfo;
25
26
use Closure;
27
use OCP\AppFramework\App;
28
use OCP\AppFramework\Bootstrap\IBootContext;
29
use OCP\AppFramework\Bootstrap\IBootstrap;
30
use OCP\AppFramework\Bootstrap\IRegistrationContext;
31
use OCP\EventDispatcher\IEventDispatcher;
32
use OCP\Notification\IManager as NotificationManager;
33
use OCP\User\Events\UserDeletedEvent;
34
use OCA\Polls\Notification\Notifier;
35
use OCA\Polls\Listener\UserDeletedListener;
36
37
class Application extends App implements IBootstrap {
38
	public const APP_ID = 'polls';
39
40
	public function __construct(array $urlParams = []) {
41
		parent::__construct(self::APP_ID, $urlParams);
42
	}
43
44
	public function boot(IBootContext $context): void {
45
		$context->injectFn(Closure::fromCallable([$this, 'registerNotifications']));
46
		$context->injectFn(Closure::fromCallable([$this, 'registerUserDeletedListener']));
47
	}
48
49
	public function register(IRegistrationContext $context): void {
50
	}
51
52
	public function registerNotifications(NotificationManager $notificationManager): void {
53
		$notificationManager->registerNotifierService(Notifier::class);
54
	}
55
56
	public function registerUserDeletedListener(): void {
57
		$eventDispatcher = $this->getContainer()->query(IEventDispatcher::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

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

57
		$eventDispatcher = /** @scrutinizer ignore-deprecated */ $this->getContainer()->query(IEventDispatcher::class);

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...
58
		$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class);
59
	}
60
}
61