HideColumns::addData()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 11
rs 10
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\Backend\FormEngine\DataProvider;
19
20
use CuyZ\Notiz\Core\Notification\TCA\EntityTcaWriter;
21
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Form\FormDataProviderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
23
/**
24
 * This provider takes care of hiding every column until the event has been
25
 * selected for the notification entity.
26
 *
27
 * This prevents unwanted behaviours for columns that require the event to be
28
 * selected.
29
 */
30
class HideColumns implements FormDataProviderInterface
31
{
32
    /**
33
     * @param array $result
34
     * @return array
35
     */
36
    public function addData(array $result): array
37
    {
38
        if (!isset($result['processedTca']['ctrl'][EntityTcaWriter::NOTIFICATION_ENTITY])) {
39
            return $result;
40
        }
41
42
        if (empty($result['databaseRow']['event'])) {
43
            $result['processedTca']['types'][0]['showitem'] = 'title,description,--div--;' . EntityTcaWriter::LLL . ':tab.event,event';
44
        }
45
46
        return $result;
47
    }
48
}
49