Passed
Push — master ( a35699...cf28ed )
by Romain
04:55 queued 02:08
created

HideColumns   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A addData() 0 13 3
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\Backend\FormEngine\DataProvider;
18
19
use CuyZ\Notiz\Core\Notification\TCA\EntityTcaWriter;
20
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
21
22
/**
23
 * This provider takes care of hiding every column until the event has been
24
 * selected for the notification entity.
25
 *
26
 * This prevents unwanted behaviours for columns that require the event to be
27
 * selected.
28
 */
29
class HideColumns implements FormDataProviderInterface
30
{
31
    /**
32
     * @param array $result
33
     * @return array
34
     */
35
    public function addData(array $result)
36
    {
37
        $tableName = $result['tableName'];
38
39
        if (!isset($GLOBALS['TCA'][$tableName]['ctrl'][EntityTcaWriter::ENTITY_NOTIFICATION])) {
40
            return $result;
41
        }
42
43
        if (empty($result['databaseRow']['event'])) {
44
            $GLOBALS['TCA'][$tableName]['types'][0]['showitem'] = 'title,description,--div--;' . EntityTcaWriter::LLL . ':tab.event,event';
45
        }
46
47
        return $result;
48
    }
49
}
50