Passed
Pull Request — master (#75)
by Nathan
04:06
created

EntitySlackTcaWriter::getCtrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * Copyright (C) 2018
5
 * Nathan Boiron <[email protected]>
6
 * Romain Canon <[email protected]>
7
 *
8
 * This file is part of the TYPO3 NotiZ project.
9
 * It is free software; you can redistribute it and/or modify it
10
 * under the terms of the GNU General Public License, either
11
 * version 3 of the License, or any later version.
12
 *
13
 * For the full copyright and license information, see:
14
 * http://www.gnu.org/licenses/gpl-3.0.html
15
 */
16
17
namespace CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\TCA;
18
19
use CuyZ\Notiz\Core\Notification\TCA\EntityTcaWriter;
20
21
class EntitySlackTcaWriter extends EntityTcaWriter
22
{
23
    const SLACK_LLL = 'LLL:EXT:notiz/Resources/Private/Language/Notification/Slack/Entity.xlf';
24
25
    /**
26
     * @return array
27
     */
28
    protected function buildTcaArray()
29
    {
30
        return [
31
            'ctrl' => $this->getCtrl(),
32
33
            'palettes' => [
34
                'content' => [
35
                    'showitem' => 'message,markers',
36
                    'canNotCollapse' => true,
37
                ],
38
                'bot' => [
39
                    'showitem' => 'custom_bot,--linebreak--,bot,name,--linebreak--,avatar',
40
                    'canNotCollapse' => true,
41
                ],
42
                'channel' => [
43
                    'showitem' => 'slack_channel',
44
                    'canNotCollapse' => true,
45
                ],
46
                'channel_custom' => [
47
                    'showitem' => 'target,--linebreak--,webhook_url',
48
                    'canNotCollapse' => true,
49
                ],
50
            ],
51
52
            'types' => [
53
                '0' => [
54
                    'showitem' => '
55
                error_message,
56
                title, sys_language_uid, hidden,
57
                --div--;' . self::LLL_TABS . ':tab.event,
58
                    event, event_configuration_flex,
59
                --div--;' . self::LLL_TABS . ':tab.channel,
60
                    channel,
61
                --div--;' . self::SLACK_LLL . ':tab.content,
62
                    --palette--;' . self::SLACK_LLL . ':palette.content;content,
63
                --div--;' . self::SLACK_LLL . ':tab.slack,
64
                    --palette--;' . self::SLACK_LLL . ':palette.bot;bot,
65
                    --palette--;' . self::SLACK_LLL . ':palette.channel;channel,
66
                    --palette--;' . self::SLACK_LLL . ':palette.channel_custom;channel_custom
67
'
68
                ]
69
            ],
70
71
            'columns' => [
72
73
                'message' => [
74
                    'exclude' => 1,
75
                    'label' => self::SLACK_LLL . ':field.message',
76
                    'config' => [
77
                        'type' => 'text',
78
                        'size' => 4000,
79
                        'eval' => 'trim,required',
80
                    ],
81
                ],
82
83
                'custom_bot' => [
84
                    'exclude' => 1,
85
                    'label' => self::SLACK_LLL . ':field.custom_bot',
86
                    'config' => [
87
                        'type' => 'check',
88
                        'default' => 0,
89
                    ],
90
                ],
91
92
                'bot' => [
93
                    'exclude' => 1,
94
                    'label' => self::SLACK_LLL . ':field.bot',
95
                    'displayCond' => 'FIELD:custom_bot:=:0',
96
                    'config' => [
97
                        'type' => 'select',
98
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getBotsList',
99
                        'size' => 1,
100
                        'maxitems' => 1,
101
                        'eval' => 'required',
102
                    ],
103
                ],
104
105
                'name' => [
106
                    'exclude' => 1,
107
                    'label' => self::SLACK_LLL . ':field.name',
108
                    'displayCond' => 'FIELD:custom_bot:=:1',
109
                    'config' => [
110
                        'type' => 'input',
111
                        'size' => 255,
112
                        'eval' => 'trim,required',
113
                    ],
114
                ],
115
116
                'avatar' => [
117
                    'exclude' => 1,
118
                    'label' => self::SLACK_LLL . ':field.avatar',
119
                    'displayCond' => 'FIELD:custom_bot:=:1',
120
                    'config' => [
121
                        'type' => 'input',
122
                        'size' => 255,
123
                        'eval' => 'trim,required',
124
                    ],
125
                ],
126
127
                'slack_channel' => [
128
                    'exclude' => 1,
129
                    'label' => self::SLACK_LLL . ':field.slack_channel',
130
                    'config' => [
131
                        'type' => 'select',
132
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getSlackChannelsList',
133
                        'renderType' => 'selectMultipleSideBySide',
134
                        'size' => 5,
135
                        'maxitems' => 128,
136
                    ],
137
                ],
138
139
                'target' => [
140
                    'exclude' => 1,
141
                    'label' => self::SLACK_LLL . ':field.target',
142
                    'config' => [
143
                        'type' => 'input',
144
                        'size' => 255,
145
                        'eval' => 'trim,required',
146
                    ],
147
                ],
148
149
                'webhook_url' => [
150
                    'exclude' => 1,
151
                    'label' => self::SLACK_LLL . ':field.webhook_url',
152
                    'config' => [
153
                        'type' => 'input',
154
                        'size' => 255,
155
                        'eval' => 'trim,required',
156
                    ],
157
                ],
158
159
            ],
160
        ];
161
    }
162
163
    /**
164
     * @return array
165
     */
166
    protected function getCtrl()
167
    {
168
        $ctrl = $this->getDefaultCtrl();
169
170
        $ctrl['title'] = self::SLACK_LLL . ':title';
171
        $ctrl['requestUpdate'] .= ',custom_bot';
172
173
        return $ctrl;
174
    }
175
176
    /**
177
     * @return string
178
     */
179
    protected function getNotificationTcaServiceClass()
180
    {
181
        return EntitySlackTcaService::class;
182
    }
183
}
184