Passed
Push — master ( c333a9...193f71 )
by Marcel
02:44
created

Application19::registerNavigationEntry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
/**
3
 * Audioplayer
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\audioplayer\AppInfo;
13
14
use OCP\AppFramework\App;
15
use OCP\Util;
16
17
class Application19 extends App
18
{
19
    public const APP_ID = 'audioplayer';
20
21
    public function __construct(array $urlParams = [])
22
    {
23
        parent::__construct(self::APP_ID, $urlParams);
24
    }
25
26
    public function register()
27
    {
28
        $this->registerNavigationEntry();
29
        $this->registerFileHooks();
30
        $this->registerUserHooks();
31
    }
32
33
    protected function registerNavigationEntry(): void
34
    {
35
        $navigationEntry = function () {
36
            return [
37
                'id' => 'audioplayer',
38
                'order' => 6,
39
                'name' => \OC::$server->getL10N('audioplayer')->t('Audio Player'),
40
                'href' => \OC::$server->getURLGenerator()->linkToRoute('audioplayer.page.index'),
41
                'icon' => \OC::$server->getURLGenerator()->imagePath('audioplayer', 'app.svg'),
42
            ];
43
        };
44
        \OC::$server->getNavigationManager()->add($navigationEntry);
45
    }
46
47
    protected function registerFileHooks()
48
    {
49
        Util::connectHook(
50
            'OC_Filesystem', 'delete', '\OCA\audioplayer\Hooks\FileHooks', 'deleteTrack'
51
        );
52
    }
53
54
    protected function registerUserHooks()
55
    {
56
        Util::connectHook(
57
            'OC_User', 'post_deleteUser', '\OCA\audioplayer\Hooks\UserHooks', 'deleteUser'
58
        );
59
    }
60
61
}