|
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
|
|
|
/** |
|
38
|
|
|
* @return array As defined in initializeResultArray() of AbstractNode |
|
39
|
|
|
*/ |
|
40
|
1 |
|
public function render() |
|
41
|
|
|
{ |
|
42
|
|
|
$propertyArray = [ |
|
43
|
1 |
|
'table' => $this->data['tableName'], |
|
44
|
1 |
|
'field' => $this->data['fieldName'], |
|
45
|
1 |
|
'row' => $this->data['databaseRow'], |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
// check, which behavior is selected |
|
49
|
1 |
|
$isBehaviorHideSelected = false; |
|
50
|
1 |
|
$isBehaviorShowSelected = false; |
|
51
|
1 |
|
$activeMapping = $this->mappingRepository->findOneByForeignTableNameAndUid( |
|
52
|
1 |
|
$propertyArray['row']['uid'], |
|
53
|
1 |
|
$propertyArray['table'] |
|
54
|
|
|
); |
|
55
|
1 |
|
if ($activeMapping instanceof Mapping) { |
|
|
|
|
|
|
56
|
1 |
|
if ($activeMapping->getBehavior() === FeatureFlagService::BEHAVIOR_HIDE) { |
|
57
|
|
|
$isBehaviorHideSelected = true; |
|
58
|
1 |
|
} elseif ($activeMapping->getBehavior() === FeatureFlagService::BEHAVIOR_SHOW) { |
|
59
|
1 |
|
$isBehaviorShowSelected = true; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
$optionElements = [ |
|
64
|
|
|
[ |
|
65
|
1 |
|
'name' => $this->getLanguageService() |
|
66
|
1 |
|
->sL('LLL:EXT:feature_flag/Resources/Private/Language/locallang.xlf:tx_featureflag_behavior.hide'), |
|
67
|
|
|
'value' => FeatureFlagService::BEHAVIOR_HIDE, |
|
68
|
1 |
|
'isSelected' => $isBehaviorHideSelected, |
|
69
|
|
|
], |
|
70
|
|
|
[ |
|
71
|
1 |
|
'name' => $this->getLanguageService() |
|
72
|
1 |
|
->sL('LLL:EXT:feature_flag/Resources/Private/Language/locallang.xlf:tx_featureflag_behavior.show'), |
|
73
|
|
|
'value' => FeatureFlagService::BEHAVIOR_SHOW, |
|
74
|
1 |
|
'isSelected' => $isBehaviorShowSelected, |
|
75
|
|
|
], |
|
76
|
|
|
]; |
|
77
|
|
|
|
|
78
|
1 |
|
return $this->renderElement($optionElements); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|