NotificationStatus::getStatus()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 14
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 19
rs 9.7998
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * Copyright (C)
6
 * Nathan Boiron <[email protected]>
7
 * Romain Canon <[email protected]>
8
 *
9
 * This file is part of the TYPO3 NotiZ project.
10
 * It is free software; you can redistribute it and/or modify it
11
 * under the terms of the GNU General Public License, either
12
 * version 3 of the License, or any later version.
13
 *
14
 * For the full copyright and license information, see:
15
 * http://www.gnu.org/licenses/gpl-3.0.html
16
 */
17
18
namespace CuyZ\Notiz\Backend\Report;
19
20
use CuyZ\Notiz\Core\Definition\DefinitionService;
21
use CuyZ\Notiz\Service\Container;
22
use CuyZ\Notiz\Service\LocalizationService;
23
use CuyZ\Notiz\Service\ViewService;
24
use TYPO3\CMS\Core\SingletonInterface;
25
use TYPO3\CMS\Reports\Status;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Reports\Status 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...
26
use TYPO3\CMS\Reports\StatusProviderInterface;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Reports\StatusProviderInterface 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...
27
28
/**
29
 * Adds an entry to the status report handled by TYPO3.
30
 *
31
 * If an error is found in the definition, an error report is added to the
32
 * queue, making it easier for administrators to see that something is wrong
33
 * with the extension.
34
 */
35
class NotificationStatus implements StatusProviderInterface, SingletonInterface
36
{
37
    /**
38
     * @var DefinitionService
39
     */
40
    protected $definitionService;
41
42
    /**
43
     * @var ViewService
44
     */
45
    protected $viewService;
46
47
    /**
48
     * Manual dependency injection.
49
     */
50
    public function __construct()
51
    {
52
        $this->definitionService = Container::get(DefinitionService::class);
53
        $this->viewService = Container::get(ViewService::class);
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    public function getStatus(): array
60
    {
61
        $result = $this->definitionService->getValidationResult();
62
63
        $viewMessage = $this->viewService->getStandaloneView('Backend/Report/NotificationStatus');
64
        $viewButtons = $this->viewService->getStandaloneView('Backend/Report/NotificationStatusButtons');
65
66
        $viewMessage->assign('result', $result);
67
        $viewButtons->assign('result', $result);
68
69
        return [
70
            Container::get(
71
                Status::class,
72
                LocalizationService::localize('Backend/Report:status.definition'),
73
                $viewMessage->render(),
74
                $viewButtons->render(),
75
                $result->hasErrors()
76
                    ? Status::ERROR
77
                    : Status::OK
78
            )
79
        ];
80
    }
81
}
82