Passed
Pull Request — master (#101)
by Romain
05:30
created

EntityEmailTcaWriter::getChannelLabel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
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\Email\Application\EntityEmail\TCA;
18
19
use CuyZ\Notiz\Core\Notification\TCA\EntityTcaWriter;
20
21
class EntityEmailTcaWriter extends EntityTcaWriter
22
{
23
    const EMAIL_LLL = 'LLL:EXT:notiz/Resources/Private/Language/Notification/Email/Entity.xlf';
24
25
    /**
26
     * @var EntityEmailTcaService
27
     */
28
    protected $service;
29
30
    /**
31
     * @return string
32
     */
33
    protected function getNotificationTcaServiceClass()
34
    {
35
        return EntityEmailTcaService::class;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    protected function getChannelLabel()
42
    {
43
        return self::EMAIL_LLL . ':field.mailer';
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    protected function buildTcaArray()
50
    {
51
        return [
52
            'ctrl' => $this->getCtrl(),
53
54
            'palettes' => [
55
                'mail' => [
56
                    'showitem' => 'subject,markers,--linebreak--,body',
57
                    'canNotCollapse' => true,
58
                ],
59
                'send_to' => [
60
                    'showitem' => 'send_to,--linebreak--,send_to_provided',
61
                    'canNotCollapse' => true,
62
                ],
63
                'send_cc' => [
64
                    'showitem' => 'send_cc,--linebreak--,send_cc_provided',
65
                    'canNotCollapse' => true,
66
                ],
67
                'send_bcc' => [
68
                    'showitem' => 'send_bcc,--linebreak--,send_bcc_provided',
69
                    'canNotCollapse' => true,
70
                ],
71
            ],
72
73
            'types' => [
74
                '0' => [
75
                    'showitem' => '
76
                        error_message,
77
                        title, sys_language_uid, hidden,
78
                        --div--;' . self::LLL_TABS . ':tab.event,
79
                            event, event_configuration_flex,
80
                        --div--;' . self::LLL_TABS . ':tab.channel,
81
                            channel,
82
                        --div--;' . self::EMAIL_LLL . ':tab.mail_configuration,
83
                            layout,
84
                            --palette--;' . self::EMAIL_LLL . ':palette.mail;mail,
85
                        --div--;' . self::EMAIL_LLL . ':tab.mail_recipients,
86
                            --palette--;' . self::EMAIL_LLL . ':palette.mail_recipients_to;send_to,
87
                            --palette--;' . self::EMAIL_LLL . ':palette.mail_recipients_cc;send_cc,
88
                            --palette--;' . self::EMAIL_LLL . ':palette.mail_recipients_bcc;send_bcc,
89
                        --div--;' . self::EMAIL_LLL . ':tab.mail_sender,
90
                            sender_custom,--linebreak--,sender,sender_default,
91
                        ',
92
                ],
93
            ],
94
95
            'columns' => [
96
97
                // Mail configuration
98
99
                'layout' => [
100
                    'exclude' => 1,
101
                    'label' => self::EMAIL_LLL . ':field.layout',
102
                    'l10n_mode' => 'exclude',
103
                    'l10n_display' => 'defaultAsReadonly',
104
                    'config' => [
105
                        'type' => 'select',
106
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getLayoutList',
107
                        'size' => 1,
108
                        'maxitems' => 1,
109
                        'eval' => 'required',
110
                    ],
111
                ],
112
113
                // Mail content
114
115
                'subject' => [
116
                    'exclude' => 1,
117
                    'label' => self::EMAIL_LLL . ':field.subject',
118
                    'config' => [
119
                        'type' => 'input',
120
                        'size' => 40,
121
                        'eval' => 'trim,required',
122
                    ],
123
                ],
124
125
                'body' => [
126
                    'exclude' => 1,
127
                    'label' => self::EMAIL_LLL . ':field.body',
128
                    'displayCond' => $this->service->getMailBodyDisplayCond(),
129
                    'config' => [
130
                        'type' => 'flex',
131
                        'ds_pointerField' => 'event',
132
                        'ds' => $this->service->getMailBodyFlexFormList(),
133
                        'behaviour' => [
134
                            'allowLanguageSynchronization' => true,
135
                        ],
136
                    ],
137
                ],
138
139
                // Sender
140
141
                'sender_custom' => [
142
                    'exclude' => 1,
143
                    'label' => self::EMAIL_LLL . ':field.sender_custom',
144
                    'config' => [
145
                        'type' => 'check',
146
                        'default' => 0,
147
                    ],
148
                ],
149
150
                'sender_default' => [
151
                    'exclude' => 1,
152
                    'label' => self::EMAIL_LLL . ':field.sender_default',
153
                    'displayCond' => 'FIELD:sender_custom:=:0',
154
                    'config' => [
155
                        'type' => 'user',
156
                        'userFunc' => $this->getNotificationTcaServiceClass() . '->getDefaultSender',
157
                    ],
158
                ],
159
160
                'sender' => [
161
                    'exclude' => 1,
162
                    'label' => self::EMAIL_LLL . ':field.sender',
163
                    'displayCond' => 'FIELD:sender_custom:=:1',
164
                    'l10n_mode' => 'exclude',
165
                    'l10n_display' => 'defaultAsReadonly',
166
                    'config' => [
167
                        'type' => 'input',
168
                        'size' => 255,
169
                        'eval' => 'email,required',
170
                        'default' => '',
171
                        'placeholder' => '[email protected]',
172
                    ],
173
                ],
174
175
                // Recipients
176
177
                'send_to' => [
178
                    'exclude' => 1,
179
                    'label' => self::EMAIL_LLL . ':field.send_to',
180
                    'config' => [
181
                        'type' => 'input',
182
                        'size' => 512,
183
                        'eval' => 'trim',
184
                        'placeholder' => '[email protected], [email protected]',
185
                    ],
186
                ],
187
188
                'send_to_provided' => [
189
                    'exclude' => 1,
190
                    'label' => self::EMAIL_LLL . ':field.send_to_provided',
191
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->shouldShowProvidedRecipientsSelect',
192
                    'config' => [
193
                        'type' => 'select',
194
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getRecipientsList',
195
                        'renderType' => 'selectMultipleSideBySide',
196
                        'size' => 5,
197
                        'maxitems' => 128,
198
                    ],
199
                ],
200
201
                'send_cc' => [
202
                    'exclude' => 1,
203
                    'label' => self::EMAIL_LLL . ':field.send_cc',
204
                    'config' => [
205
                        'type' => 'input',
206
                        'size' => 512,
207
                        'eval' => 'trim',
208
                        'placeholder' => '[email protected], [email protected]',
209
                    ],
210
                ],
211
212
                'send_cc_provided' => [
213
                    'exclude' => 1,
214
                    'label' => self::EMAIL_LLL . ':field.send_cc_provided',
215
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->shouldShowProvidedRecipientsSelect',
216
                    'config' => [
217
                        'type' => 'select',
218
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getRecipientsList',
219
                        'renderType' => 'selectMultipleSideBySide',
220
                        'size' => 5,
221
                        'maxitems' => 128,
222
                    ],
223
                ],
224
225
                'send_bcc' => [
226
                    'exclude' => 1,
227
                    'label' => self::EMAIL_LLL . ':field.send_bcc',
228
                    'config' => [
229
                        'type' => 'input',
230
                        'size' => 512,
231
                        'eval' => 'trim',
232
                        'placeholder' => '[email protected], [email protected]',
233
                    ],
234
                ],
235
236
                'send_bcc_provided' => [
237
                    'exclude' => 1,
238
                    'label' => self::EMAIL_LLL . ':field.send_bcc_provided',
239
                    'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->shouldShowProvidedRecipientsSelect',
240
                    'config' => [
241
                        'type' => 'select',
242
                        'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getRecipientsList',
243
                        'renderType' => 'selectMultipleSideBySide',
244
                        'size' => 5,
245
                        'maxitems' => 128,
246
                    ],
247
                ],
248
249
            ],
250
        ];
251
    }
252
253
    /**
254
     * @return array
255
     */
256
    protected function getCtrl()
257
    {
258
        $ctrl = $this->getDefaultCtrl();
259
260
        $ctrl['requestUpdate'] .= ',sender_custom';
261
        $ctrl['searchFields'] .= ',sender,sender_custom,send_to,send_to_provided,send_cc,send_cc_provided,send_bcc,send_bcc_provided,subject,body';
262
263
        return $ctrl;
264
    }
265
266
    /**
267
     * @return string
268
     */
269
    protected function getEntityTitle()
270
    {
271
        return self::EMAIL_LLL . ':title';
272
    }
273
}
274