Passed
Push — master ( 3afc34...d669d4 )
by Romain
05:13
created

EntitySlackTcaWriter::getCtrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A EntitySlackTcaWriter::getNotificationTcaServiceClass() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * Copyright (C) 2018
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, sys_language_uid, 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
                        'size' => 4000,
80
                        'eval' => 'trim,required',
81
                    ],
82
                ],
83
84
                'custom_bot' => [
85
                    'exclude' => 1,
86
                    'label' => self::SLACK_LLL . ':field.custom_bot',
87
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->hasDefinedBot',
88
                    'onChange' => 'reload',
89
                    'config' => [
90
                        'type' => 'check',
91
                        'default' => 1,
92
                    ],
93
                ],
94
95
                'bot' => [
96
                    'exclude' => 1,
97
                    'label' => self::SLACK_LLL . ':field.bot',
98
                    'displayCond' => [
99
                        'AND' => [
100
                            'FIELD:custom_bot:=:0',
101
                            'USER:' . $this->getNotificationTcaServiceClass() . '->hasDefinedBot',
102
                        ],
103
                    ],
104
                    'config' => [
105
                        'type' => 'select',
106
                        'renderType' => 'selectSingle',
107
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getBotsList',
108
                        'size' => 1,
109
                        'maxitems' => 1,
110
                        'eval' => 'required',
111
                    ],
112
                ],
113
114
                'no_defined_bot' => [
115
                    'label' => self::SLACK_LLL . ':field.no_defined_bot',
116
                    'displayCond' => [
117
                        'AND' => [
118
                            'FIELD:custom_bot:=:0',
119
                            'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedBot',
120
                        ],
121
                    ],
122
                    'config' => [
123
                        'type' => 'user',
124
                        'userFunc' => $this->getNotificationTcaServiceClass() . '->getNoDefinedBotText',
125
                    ],
126
                ],
127
128
                'name' => [
129
                    'exclude' => 1,
130
                    'label' => self::SLACK_LLL . ':field.name',
131
                    'displayCond' => [
132
                        'OR' => [
133
                            'FIELD:custom_bot:=:1',
134
                            'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedBot',
135
                        ],
136
                    ],
137
                    'config' => [
138
                        'type' => 'input',
139
                        'size' => 255,
140
                        'eval' => 'trim,required',
141
                    ],
142
                ],
143
144
                'avatar' => [
145
                    'exclude' => 1,
146
                    'label' => self::SLACK_LLL . ':field.avatar',
147
                    'displayCond' => [
148
                        'OR' => [
149
                            'FIELD:custom_bot:=:1',
150
                            'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedBot',
151
                        ],
152
                    ],
153
                    'config' => [
154
                        'type' => 'input',
155
                        'size' => 255,
156
                        'eval' => 'trim,required',
157
                    ],
158
                ],
159
160
                'no_defined_slack_channel' => [
161
                    'label' => self::SLACK_LLL . ':field.no_defined_slack_channel',
162
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedSlackChannel',
163
                    'config' => [
164
                        'type' => 'user',
165
                        'userFunc' => $this->getNotificationTcaServiceClass() . '->getNoDefinedSlackChannelText',
166
                    ],
167
                ],
168
169
                'slack_channel' => [
170
                    'exclude' => 1,
171
                    'label' => self::SLACK_LLL . ':field.slack_channel',
172
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->hasDefinedSlackChannel',
173
                    'config' => [
174
                        'type' => 'select',
175
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getSlackChannelsList',
176
                        'renderType' => 'selectMultipleSideBySide',
177
                        'size' => 5,
178
                        'maxitems' => 128,
179
                    ],
180
                ],
181
182
                'target' => [
183
                    'exclude' => 1,
184
                    'label' => self::SLACK_LLL . ':field.target',
185
                    'config' => [
186
                        'type' => 'input',
187
                        'size' => 255,
188
                        'eval' => 'trim,required',
189
                    ],
190
                ],
191
192
                'webhook_url' => [
193
                    'exclude' => 1,
194
                    'label' => self::SLACK_LLL . ':field.webhook_url',
195
                    'config' => [
196
                        'type' => 'input',
197
                        'size' => 255,
198
                        'eval' => 'trim,required',
199
                    ],
200
                ],
201
202
            ],
203
        ];
204
    }
205
206
    /**
207
     * @return string
208
     */
209
    protected function getNotificationTcaServiceClass(): string
210
    {
211
        return EntitySlackTcaService::class;
212
    }
213
214
    /**
215
     * @return string
216
     */
217
    protected function getEntityTitle(): string
218
    {
219
        return self::SLACK_LLL . ':title';
220
    }
221
}
222