EntitySlackTcaWriter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 199
Duplicated Lines 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
eloc 122
c 6
b 0
f 0
dl 0
loc 199
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getNotificationTcaServiceClass() 0 3 1
A getEntityTitle() 0 3 1
B buildTcaArray() 0 171 1
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\Domain\Notification\Slack\Application\EntitySlack\TCA;
19
20
use CuyZ\Notiz\Core\Notification\TCA\EntityTcaWriter;
21
22
class EntitySlackTcaWriter extends EntityTcaWriter
23
{
24
    const SLACK_LLL = 'LLL:EXT:notiz/Resources/Private/Language/Notification/Slack/Slack.xlf';
25
26
    /**
27
     * @return array
28
     */
29
    protected function buildTcaArray(): array
30
    {
31
        return [
32
            'ctrl' => $this->getDefaultCtrl(),
33
34
            'palettes' => [
35
                'content' => [
36
                    'showitem' => 'message,markers',
37
                    'canNotCollapse' => true,
38
                ],
39
                'bot' => [
40
                    'showitem' => 'custom_bot,--linebreak--,name,avatar,bot,--linebreak--,no_defined_bot',
41
                    'canNotCollapse' => true,
42
                ],
43
                'channel' => [
44
                    'showitem' => 'slack_channel,no_defined_slack_channel',
45
                    'canNotCollapse' => true,
46
                ],
47
                'channel_custom' => [
48
                    'showitem' => 'target,--linebreak--,webhook_url',
49
                    'canNotCollapse' => true,
50
                ],
51
            ],
52
53
            'types' => [
54
                '0' => [
55
                    'showitem' => '
56
                error_message,
57
                title, description, hidden,
58
                --div--;' . self::LLL . ':tab.event,
59
                    event, event_configuration_flex,
60
                --div--;' . self::LLL . ':tab.channel,
61
                    channel,
62
                --div--;' . self::SLACK_LLL . ':tab.content,
63
                    --palette--;' . self::SLACK_LLL . ':palette.content;content,
64
                --div--;' . self::SLACK_LLL . ':tab.slack,
65
                    --palette--;' . self::SLACK_LLL . ':palette.bot;bot,
66
                    --palette--;' . self::SLACK_LLL . ':palette.channel;channel,
67
                    --palette--;' . self::SLACK_LLL . ':palette.channel_custom;channel_custom
68
'
69
                ]
70
            ],
71
72
            'columns' => [
73
74
                'message' => [
75
                    'exclude' => 1,
76
                    'label' => self::SLACK_LLL . ':field.message',
77
                    'config' => [
78
                        'type' => 'text',
79
                        'default' => '',
80
                        'size' => 4000,
81
                        'eval' => 'trim,required',
82
                    ],
83
                ],
84
85
                'custom_bot' => [
86
                    'exclude' => 1,
87
                    'label' => self::SLACK_LLL . ':field.custom_bot',
88
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->hasDefinedBot',
89
                    'onChange' => 'reload',
90
                    'config' => [
91
                        'type' => 'check',
92
                        'default' => 1,
93
                    ],
94
                ],
95
96
                'bot' => [
97
                    'exclude' => 1,
98
                    'label' => self::SLACK_LLL . ':field.bot',
99
                    'displayCond' => [
100
                        'AND' => [
101
                            'FIELD:custom_bot:=:0',
102
                            'USER:' . $this->getNotificationTcaServiceClass() . '->hasDefinedBot',
103
                        ],
104
                    ],
105
                    'config' => [
106
                        'type' => 'select',
107
                        'renderType' => 'selectSingle',
108
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getBotsList',
109
                        'size' => 1,
110
                        'maxitems' => 1,
111
                        'eval' => 'required',
112
                    ],
113
                ],
114
115
                'no_defined_bot' => [
116
                    'label' => self::SLACK_LLL . ':field.no_defined_bot',
117
                    'displayCond' => [
118
                        'AND' => [
119
                            'FIELD:custom_bot:=:0',
120
                            'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedBot',
121
                        ],
122
                    ],
123
                    'config' => [
124
                        'type' => 'user',
125
                        'userFunc' => $this->getNotificationTcaServiceClass() . '->getNoDefinedBotText',
126
                    ],
127
                ],
128
129
                'name' => [
130
                    'exclude' => 1,
131
                    'label' => self::SLACK_LLL . ':field.name',
132
                    'displayCond' => [
133
                        'OR' => [
134
                            'FIELD:custom_bot:=:1',
135
                            'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedBot',
136
                        ],
137
                    ],
138
                    'config' => [
139
                        'type' => 'input',
140
                        'size' => 255,
141
                        'eval' => 'trim,required',
142
                    ],
143
                ],
144
145
                'avatar' => [
146
                    'exclude' => 1,
147
                    'label' => self::SLACK_LLL . ':field.avatar',
148
                    'displayCond' => [
149
                        'OR' => [
150
                            'FIELD:custom_bot:=:1',
151
                            'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedBot',
152
                        ],
153
                    ],
154
                    'config' => [
155
                        'type' => 'input',
156
                        'size' => 255,
157
                        'eval' => 'trim,required',
158
                    ],
159
                ],
160
161
                'no_defined_slack_channel' => [
162
                    'label' => self::SLACK_LLL . ':field.no_defined_slack_channel',
163
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedSlackChannel',
164
                    'config' => [
165
                        'type' => 'user',
166
                        'userFunc' => $this->getNotificationTcaServiceClass() . '->getNoDefinedSlackChannelText',
167
                    ],
168
                ],
169
170
                'slack_channel' => [
171
                    'exclude' => 1,
172
                    'label' => self::SLACK_LLL . ':field.slack_channel',
173
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->hasDefinedSlackChannel',
174
                    'config' => [
175
                        'type' => 'select',
176
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getSlackChannelsList',
177
                        'renderType' => 'selectMultipleSideBySide',
178
                        'size' => 5,
179
                        'maxitems' => 128,
180
                    ],
181
                ],
182
183
                'target' => [
184
                    'exclude' => 1,
185
                    'label' => self::SLACK_LLL . ':field.target',
186
                    'config' => [
187
                        'type' => 'input',
188
                        'size' => 255,
189
                        'eval' => 'trim',
190
                    ],
191
                ],
192
193
                'webhook_url' => [
194
                    'exclude' => 1,
195
                    'label' => self::SLACK_LLL . ':field.webhook_url',
196
                    'config' => [
197
                        'type' => 'input',
198
                        'size' => 255,
199
                        'eval' => 'trim',
200
                    ],
201
                ],
202
203
            ],
204
        ];
205
    }
206
207
    /**
208
     * @return string
209
     */
210
    protected function getNotificationTcaServiceClass(): string
211
    {
212
        return EntitySlackTcaService::class;
213
    }
214
215
    /**
216
     * @return string
217
     */
218
    protected function getEntityTitle(): string
219
    {
220
        return self::SLACK_LLL . ':title';
221
    }
222
}
223