Passed
Push — master ( ab8831...0ea5ed )
by Marcel
02:36
created

Application   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 41
rs 10
c 4
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 7 1
A boot() 0 3 1
A registerNavigationEntry() 0 12 1
A registerNotifications() 0 4 1
A __construct() 0 3 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\Dashboard\Widget;
15
use OCA\Analytics\Flow\FlowOperation;
16
use OCA\Analytics\Listener\LoadAdditionalScripts;
17
use OCA\Analytics\Notification\Notifier;
18
use OCA\Analytics\Search\Provider;
19
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...
20
use OCP\AppFramework\App;
21
use OCP\AppFramework\Bootstrap\IBootContext;
22
use OCP\AppFramework\Bootstrap\IBootstrap;
23
use OCP\AppFramework\Bootstrap\IRegistrationContext;
24
25
class Application extends App implements IBootstrap
26
{
27
    public const APP_ID = 'analytics';
28
29
    public function __construct(array $urlParams = [])
30
    {
31
        parent::__construct(self::APP_ID, $urlParams);
32
    }
33
34
    public function register(IRegistrationContext $context): void
35
    {
36
        $context->registerDashboardWidget(Widget::class);
37
        $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
38
        $context->registerSearchProvider(Provider::class);
39
        $this->registerNavigationEntry();
40
        $this->registerNotifications();
41
    }
42
43
    public function boot(IBootContext $context): void
44
    {
45
        $this->getContainer()->query(FlowOperation::class)->register();
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

45
        /** @scrutinizer ignore-deprecated */ $this->getContainer()->query(FlowOperation::class)->register();

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...
46
    }
47
48
    protected function registerNotifications(): void
49
    {
50
        $notificationManager = \OC::$server->getNotificationManager();
51
        $notificationManager->registerNotifierService(Notifier::class);
52
    }
53
54
    protected function registerNavigationEntry(): void
55
    {
56
        $navigationEntry = function () {
57
            return [
58
                'id' => 'analytics',
59
                'order' => 6,
60
                'name' => \OC::$server->getL10N('analytics')->t('Analytics'),
61
                'href' => \OC::$server->getURLGenerator()->linkToRoute('analytics.page.index'),
62
                'icon' => \OC::$server->getURLGenerator()->imagePath('analytics', 'app.svg'),
63
            ];
64
        };
65
        \OC::$server->getNavigationManager()->add($navigationEntry);
66
    }
67
68
}