Passed
Push — master ( 9e7c9c...370ffa )
by Marcel
02:24
created

Application19   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 43
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 14 2
A registerNotifications() 0 4 1
A __construct() 0 3 1
A registerNavigationEntry() 0 12 1
1
<?php
2
/**
3
 * Analytics
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the LICENSE.md file.
7
 *
8
 * @author Marcel Scherello <[email protected]>
9
 * @copyright 2020 Marcel Scherello
10
 */
11
12
namespace OCA\Analytics\AppInfo;
13
14
use OCA\Analytics\Flow\Operation;
15
use OCA\Analytics\Notification\Notifier;
16
use OCP\AppFramework\App;
17
use OCP\AppFramework\QueryException;
18
use OCP\EventDispatcher\IEventDispatcher;
19
20
class Application19 extends App
21
{
22
    public const APP_ID = 'analytics';
23
24
    public function __construct(array $urlParams = [])
25
    {
26
        parent::__construct(self::APP_ID, $urlParams);
27
    }
28
29
    public function register()
30
    {
31
        $this->registerNotifications();
32
        $this->registerNavigationEntry();
33
34
        $server = $this->getContainer()->getServer();
35
        /** @var IEventDispatcher $dispatcher */
36
        try {
37
            $dispatcher = $server->query(IEventDispatcher::class);
38
        } catch (QueryException $e) {
39
            // no action
40
        }
41
42
        Operation::register($dispatcher);
43
    }
44
45
    public function registerNotifications(): void
46
    {
47
        $notificationManager = \OC::$server->getNotificationManager();
48
        $notificationManager->registerNotifierService(Notifier::class);
49
    }
50
51
    protected function registerNavigationEntry(): void
52
    {
53
        $navigationEntry = function () {
54
            return [
55
                'id' => 'analytics',
56
                'order' => 6,
57
                'name' => \OC::$server->getL10N('analytics')->t('Analytics'),
58
                'href' => \OC::$server->getURLGenerator()->linkToRoute('analytics.page.index'),
59
                'icon' => \OC::$server->getURLGenerator()->imagePath('analytics', 'app.svg'),
60
            ];
61
        };
62
        \OC::$server->getNavigationManager()->add($navigationEntry);
63
    }
64
65
}