1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aoe\FeatureFlag\Form\Element; |
4
|
|
|
|
5
|
|
|
use Aoe\FeatureFlag\Domain\Model\Mapping; |
6
|
|
|
use Aoe\FeatureFlag\Service\FeatureFlagService; |
7
|
|
|
|
8
|
|
|
/*************************************************************** |
9
|
|
|
* Copyright notice |
10
|
|
|
* |
11
|
|
|
* (c) 2021 AOE GmbH <[email protected]> |
12
|
|
|
* |
13
|
|
|
* All rights reserved |
14
|
|
|
* |
15
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
16
|
|
|
* free software; you can redistribute it and/or modify |
17
|
|
|
* it under the terms of the GNU General Public License as published by |
18
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
19
|
|
|
* (at your option) any later version. |
20
|
|
|
* |
21
|
|
|
* The GNU General Public License can be found at |
22
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
23
|
|
|
* |
24
|
|
|
* This script is distributed in the hope that it will be useful, |
25
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
26
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
27
|
|
|
* GNU General Public License for more details. |
28
|
|
|
* |
29
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
30
|
|
|
***************************************************************/ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* This is rendered for type=user, renderType=selectFeatureFlagBehaviour |
34
|
|
|
*/ |
35
|
|
|
class FeatureFlagBehaviourFormSelectElement extends AbstractFormSelectElement |
36
|
|
|
{ |
37
|
|
|
public function render(): array |
38
|
|
|
{ |
39
|
|
|
$propertyArray = [ |
40
|
|
|
'table' => $this->data['tableName'], |
41
|
|
|
'field' => $this->data['fieldName'], |
42
|
|
|
'row' => $this->data['databaseRow'], |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
// check, which behavior is selected |
46
|
|
|
$isBehaviorHideSelected = false; |
47
|
|
|
$isBehaviorShowSelected = false; |
48
|
|
|
$activeMapping = $this->mappingRepository->findOneByForeignTableNameAndUid( |
49
|
|
|
$propertyArray['row']['uid'], |
50
|
|
|
$propertyArray['table'] |
51
|
|
|
); |
52
|
|
|
if ($activeMapping instanceof Mapping) { |
53
|
|
|
if ($activeMapping->getBehavior() === FeatureFlagService::BEHAVIOR_HIDE) { |
54
|
|
|
$isBehaviorHideSelected = true; |
55
|
|
|
} elseif ($activeMapping->getBehavior() === FeatureFlagService::BEHAVIOR_SHOW) { |
56
|
|
|
$isBehaviorShowSelected = true; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$optionElements = [ |
61
|
|
|
[ |
62
|
|
|
'name' => $this->getLanguageService() |
63
|
|
|
->sL('LLL:EXT:feature_flag/Resources/Private/Language/locallang.xlf:tx_featureflag_behavior.hide'), |
64
|
|
|
'value' => FeatureFlagService::BEHAVIOR_HIDE, |
65
|
|
|
'isSelected' => $isBehaviorHideSelected, |
66
|
|
|
], |
67
|
|
|
[ |
68
|
|
|
'name' => $this->getLanguageService() |
69
|
|
|
->sL('LLL:EXT:feature_flag/Resources/Private/Language/locallang.xlf:tx_featureflag_behavior.show'), |
70
|
|
|
'value' => FeatureFlagService::BEHAVIOR_SHOW, |
71
|
|
|
'isSelected' => $isBehaviorShowSelected, |
72
|
|
|
], |
73
|
|
|
]; |
74
|
|
|
|
75
|
|
|
return $this->renderElement($optionElements); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|