TablesConfigurationService::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
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\Service\Extension;
19
20
use CuyZ\Notiz\Backend\Report\NotificationStatus;
21
use CuyZ\Notiz\Backend\FormEngine\ButtonBar\ShowNotificationDetailsButton;
22
use CuyZ\Notiz\Backend\Module\ManagerModuleHandler;
23
use CuyZ\Notiz\Core\Support\NotizConstants;
24
use CuyZ\Notiz\Service\Traits\SelfInstantiateTrait;
25
use TYPO3\CMS\Backend\Controller\EditDocumentController;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Contro...\EditDocumentController 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\Core\SingletonInterface;
27
use TYPO3\CMS\Core\Utility\GeneralUtility;
28
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\SignalSlot\Dispatcher 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...
29
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\Utility\ExtensionUtility 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...
30
31
/**
32
 * This class replaces the old-school procedural way of handling configuration
33
 * in `ext_tables.php` file.
34
 *
35
 * @internal
36
 */
37
class TablesConfigurationService implements SingletonInterface
38
{
39
    use SelfInstantiateTrait;
40
41
    /**
42
     * @var string
43
     */
44
    protected $extensionKey;
45
46
    /**
47
     * @var Dispatcher
48
     */
49
    protected $dispatcher;
50
51
    /**
52
     * Manual dependency injection.
53
     */
54
    public function __construct()
55
    {
56
        $this->extensionKey = NotizConstants::EXTENSION_KEY;
57
        $this->dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
58
    }
59
60
    /**
61
     * Main processing methods that will call every method of this class.
62
     */
63
    public function process()
64
    {
65
        $this->registerBackendModule();
66
        $this->registerDetailViewButton();
67
        $this->registerEntityNotificationControllers();
68
        $this->registerReportStatus();
69
    }
70
71
    /**
72
     * Registers the main backend module used to display notifications,
73
     * definition and more.
74
     */
75
    protected function registerBackendModule()
76
    {
77
        ExtensionUtility::registerModule(
78
            'CuyZ.Notiz',
79
            'notiz',
80
            '',
81
            '',
82
            [],
83
            [
84
                'access' => '',
85
                'icon' => '',
86
                'iconIdentifier' => 'tx-notiz-icon-main-module',
87
                'labels' => "LLL:EXT:{$this->extensionKey}/Resources/Private/Language/Backend/Module/Main/Main.xlf",
88
                'sub' => []
89
            ]
90
        );
91
92
        ExtensionUtility::registerModule(
93
            'CuyZ.Notiz',
94
            'notiz',
95
            'notiz_manager',
96
            '',
97
            [
98
                'Backend\Manager\ListNotificationTypes' => 'process',
99
                'Backend\Manager\ListNotifications' => 'process',
100
                'Backend\Manager\NotificationActivation' => 'process',
101
                'Backend\Manager\ListEvents' => 'process',
102
                'Backend\Manager\ShowEvent' => 'process',
103
            ],
104
            [
105
                'access' => 'user,group',
106
                'icon' => NotizConstants::EXTENSION_ICON_PATH_MODULE_MANAGER,
107
                'labels' => "LLL:EXT:{$this->extensionKey}/Resources/Private/Language/Backend/Module/Manager/Manager.xlf",
108
            ]
109
        );
110
111
        ExtensionUtility::registerModule(
112
            'CuyZ.Notiz',
113
            'notiz',
114
            'notiz_administration',
115
            '',
116
            [
117
                'Backend\Administration\Index' => 'process',
118
                'Backend\Administration\ShowDefinition' => 'process',
119
                'Backend\Administration\ShowException' => 'process',
120
            ],
121
            [
122
                'access' => 'admin',
123
                'icon' => NotizConstants::EXTENSION_ICON_PATH_MODULE_ADMINISTRATION,
124
                'labels' => "LLL:EXT:{$this->extensionKey}/Resources/Private/Language/Backend/Module/Administration/Administration.xlf",
125
            ]
126
        );
127
    }
128
129
    /**
130
     * @see ShowNotificationDetailsButton
131
     */
132
    protected function registerDetailViewButton()
133
    {
134
        $this->dispatcher->connect(
135
            EditDocumentController::class,
136
            'initAfter',
137
            ShowNotificationDetailsButton::class,
138
            'addButton'
139
        );
140
    }
141
142
    /**
143
     * Dynamically registers the controllers for existing entity notifications.
144
     */
145
    protected function registerEntityNotificationControllers()
146
    {
147
        ManagerModuleHandler::get()->registerEntityNotificationControllers();
0 ignored issues
show
Bug introduced by
It seems like registerEntityNotificationControllers() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

147
        ManagerModuleHandler::get()->/** @scrutinizer ignore-call */ registerEntityNotificationControllers();
Loading history...
148
    }
149
150
    /**
151
     * @see \CuyZ\Notiz\Backend\Report\NotificationStatus
152
     */
153
    protected function registerReportStatus()
154
    {
155
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['NotiZ'][] = NotificationStatus::class;
156
    }
157
}
158