|
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\Core\Notification\TCA\Processor; |
|
18
|
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Core\Notification\Service\LegacyNotificationTcaService; |
|
20
|
|
|
use TYPO3\CMS\Core\Utility\VersionNumberUtility; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Builds the TCA array for the event configuration. |
|
24
|
|
|
* |
|
25
|
|
|
* It is a FlexForm field, with as many definition sheets as there are events |
|
26
|
|
|
* using FlexForm. Display conditions are dynamically assigned to show the |
|
27
|
|
|
* correct definition depending on the selected event. |
|
28
|
|
|
*/ |
|
29
|
|
|
class EventConfigurationProcessor extends GracefulProcessor |
|
30
|
|
|
{ |
|
31
|
|
|
const COLUMN = 'event_configuration_flex'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param string $tableName |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function doProcess($tableName) |
|
37
|
|
|
{ |
|
38
|
|
|
$flexFormDs = []; |
|
39
|
|
|
$displayConditions = []; |
|
40
|
|
|
|
|
41
|
|
|
foreach ($this->definitionService->getDefinition()->getEvents() as $event) { |
|
42
|
|
|
$provider = $event->getConfiguration()->getFlexFormProvider(); |
|
43
|
|
|
|
|
44
|
|
|
if ($provider->hasFlexForm()) { |
|
45
|
|
|
$identifier = $event->getFullIdentifier(); |
|
46
|
|
|
|
|
47
|
|
|
$flexFormDs[$identifier] = $provider->getFlexFormValue(); |
|
48
|
|
|
$displayConditions[] = $identifier; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
// If no definition is found, the field is not shown at all. |
|
53
|
|
|
if (empty($flexFormDs)) { |
|
54
|
|
|
$GLOBALS['TCA'][$tableName]['columns'][self::COLUMN]['config'] = ['type' => 'passthrough']; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @deprecated Value can be empty when TYPO3 v7 is not supported anymore. |
|
59
|
|
|
*/ |
|
60
|
|
|
$flexFormDs['default'] = 'FILE:EXT:notiz/Configuration/FlexForm/Event/DefaultEventFlexForm.xml'; |
|
61
|
|
|
|
|
62
|
|
|
$GLOBALS['TCA'][$tableName]['columns'][self::COLUMN]['config']['ds'] = $flexFormDs; |
|
63
|
|
|
|
|
64
|
|
|
$GLOBALS['TCA'][$tableName]['columns'][self::COLUMN]['displayCond'] = version_compare(VersionNumberUtility::getCurrentTypo3Version(), '8.0.0', '<') |
|
65
|
|
|
? 'USER:' . LegacyNotificationTcaService::class . '->displayEventFlexForm:' . $tableName . ':' . implode(',', $displayConditions) |
|
66
|
|
|
: 'FIELD:event:IN:' . implode(',', $displayConditions); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|