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

Application20::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 OCA\audioplayer\Listener\LoadAdditionalScripts;
15
use OCA\audioplayer\Search\Provider;
16
use OCA\Files\Event\LoadAdditionalScriptsEvent;
0 ignored issues
show
Bug introduced by
The type OCA\Files\Event\LoadAdditionalScriptsEvent was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
0 ignored issues
show
Bug introduced by
The type OCA\Files_Sharing\Event\...reTemplateRenderedEvent was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use OCP\AppFramework\App;
19
use OCP\AppFramework\Bootstrap\IBootContext;
0 ignored issues
show
Bug introduced by
The type OCP\AppFramework\Bootstrap\IBootContext was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use OCP\AppFramework\Bootstrap\IBootstrap;
0 ignored issues
show
Bug introduced by
The type OCP\AppFramework\Bootstrap\IBootstrap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use OCP\AppFramework\Bootstrap\IRegistrationContext;
0 ignored issues
show
Bug introduced by
The type OCP\AppFramework\Bootstrap\IRegistrationContext was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use OCP\Util;
23
24
class Application20 extends App implements IBootstrap
25
{
26
    public const APP_ID = 'audioplayer';
27
28
    public function __construct(array $urlParams = [])
29
    {
30
        parent::__construct(self::APP_ID, $urlParams);
31
    }
32
33
    public function register(IRegistrationContext $context): void
34
    {
35
        $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
36
        $context->registerEventListener(BeforeTemplateRenderedEvent::class, LoadAdditionalScripts::class);
37
        $context->registerSearchProvider(Provider::class);
38
        $this->registerNavigationEntry();
39
        $this->registerFileHooks();
40
        $this->registerUserHooks();
41
    }
42
43
    protected function registerNavigationEntry(): void
44
    {
45
        $navigationEntry = function () {
46
            return [
47
                'id' => 'audioplayer',
48
                'order' => 6,
49
                'name' => \OC::$server->getL10N('audioplayer')->t('Audio Player'),
50
                'href' => \OC::$server->getURLGenerator()->linkToRoute('audioplayer.page.index'),
51
                'icon' => \OC::$server->getURLGenerator()->imagePath('audioplayer', 'app.svg'),
52
            ];
53
        };
54
        \OC::$server->getNavigationManager()->add($navigationEntry);
55
    }
56
57
    protected function registerFileHooks()
58
    {
59
        Util::connectHook(
60
            'OC_Filesystem', 'delete', '\OCA\audioplayer\Hooks\FileHooks', 'deleteTrack'
61
        );
62
    }
63
64
    protected function registerUserHooks()
65
    {
66
        Util::connectHook(
67
            'OC_User', 'post_deleteUser', '\OCA\audioplayer\Hooks\UserHooks', 'deleteUser'
68
        );
69
    }
70
71
    public function boot(IBootContext $context): void
72
    {
73
    }
74
75
}