/
SelectSettings.php
170 lines (143 loc) · 3.74 KB
/
SelectSettings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
namespace Concrete\Core\Entity\Attribute\Key\Settings;
use Concrete\Core\Entity\Attribute\Value\Value\SelectValue;
use Concrete\Core\Entity\Attribute\Value\Value\SelectValueOptionList;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="atSelectSettings")
*/
class SelectSettings extends Settings
{
public function __construct()
{
$this->list = new SelectValueOptionList();
}
/**
* @ORM\OneToOne(targetEntity="Concrete\Core\Entity\Attribute\Value\Value\SelectValueOptionList", cascade={"all"})
* @ORM\JoinColumn(name="avSelectOptionListID", referencedColumnName="avSelectOptionListID")
*/
protected $list;
/**
* @return mixed
*/
public function getOptionList()
{
return $this->list;
}
/**
* @param mixed $list
*/
public function setOptionList($list)
{
$this->list = $list;
}
/**
* @ORM\Column(type="boolean")
*/
protected $akSelectAllowMultipleValues = false;
/**
* @ORM\Column(type="boolean")
*/
protected $akSelectAllowOtherValues = false;
/**
* @ORM\Column(type="boolean")
*/
protected $akHideNoneOption = false;
/**
* @ORM\Column(type="string")
*/
protected $akSelectOptionDisplayOrder = 'display_asc';
/**
* @ORM\Column(type="boolean")
*/
protected $akDisplayMultipleValuesOnSelect = false;
/**
* @return mixed
*/
public function getAllowMultipleValues()
{
return $this->akSelectAllowMultipleValues;
}
/**
* @param mixed $allowMultipleValues
*/
public function setAllowMultipleValues($allowMultipleValues)
{
$this->akSelectAllowMultipleValues = $allowMultipleValues;
}
/**
* @return mixed
*/
public function getAllowOtherValues()
{
return $this->akSelectAllowOtherValues;
}
/**
* @param bool $akHideNoneOption
*/
public function setHideNoneOption($akHideNoneOption)
{
$this->akHideNoneOption = $akHideNoneOption;
}
/**
* @return bool
*/
public function getHideNoneOption()
{
return $this->akHideNoneOption;
}
/**
* @param mixed $allowOtherValues
*/
public function setAllowOtherValues($allowOtherValues)
{
$this->akSelectAllowOtherValues = $allowOtherValues;
}
/**
* @return mixed
*/
public function getDisplayOrder()
{
return $this->akSelectOptionDisplayOrder;
}
/**
* @param mixed $displayOrder
*/
public function setDisplayOrder($displayOrder)
{
$this->akSelectOptionDisplayOrder = $displayOrder;
}
/**
* @return mixed
*/
public function getDisplayMultipleValuesOnSelect()
{
return $this->akDisplayMultipleValuesOnSelect;
}
/**
* @param mixed $displayMultipleValuesOnSelect
*/
public function setDisplayMultipleValuesOnSelect($displayMultipleValuesOnSelect)
{
$this->akDisplayMultipleValuesOnSelect = $displayMultipleValuesOnSelect;
}
public function mergeAndPersist(EntityManagerInterface $entityManager)
{
$tempOptions = array();
foreach($this->list->getOptions() as $option) {
if (!$option->getSelectAttributeOptionID()) {
$tempOptions[] = $option;
$this->list->getOptions()->removeElement($option);
}
}
$settings = $entityManager->merge($this);
foreach($tempOptions as $option) {
$option->setOptionList($settings->list);
$settings->list->getOptions()->add($option);
}
$entityManager->persist($settings);
return $settings;
}
}