1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Webcook security bundle. |
5
|
|
|
* |
6
|
|
|
* See LICENSE file in the root of the bundle. Webcook |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Webcook\Cms\SecurityBundle\Entity; |
10
|
|
|
|
11
|
|
|
use Doctrine\ORM\Mapping as ORM; |
12
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
13
|
|
|
use Webcook\Cms\CoreBundle\Base\BasicEntity; |
14
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
15
|
|
|
use ApiPlatform\Core\Annotation\ApiProperty; |
16
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* System setting entity. |
20
|
|
|
* |
21
|
|
|
* @ApiResource |
22
|
|
|
* @ORM\Table(name="Setting", uniqueConstraints={ |
23
|
|
|
* @ORM\UniqueConstraint(name="uniqueSetting", columns={"key1", "section", "user_id"}) |
24
|
|
|
* }) |
25
|
|
|
* @ORM\Entity() |
26
|
|
|
*/ |
27
|
|
|
class Setting extends BasicEntity |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Name of the setting. |
31
|
|
|
* |
32
|
|
|
* @ORM\Column(type="string", length=25, nullable=false) |
33
|
|
|
* @Assert\NotNull |
34
|
|
|
* @Assert\NotBlank |
35
|
|
|
*/ |
36
|
|
|
private $name; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Key of the setting. |
40
|
|
|
* |
41
|
|
|
* @ORM\Column(name="key1", type="string", length=64, nullable=false) |
42
|
|
|
* @Assert\NotNull |
43
|
|
|
* @Assert\NotBlank |
44
|
|
|
*/ |
45
|
|
|
private $key; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Value of the setting. |
49
|
|
|
* |
50
|
|
|
* @ORM\Column(type="string", length=60, nullable=false) |
51
|
|
|
* @Assert\NotNull |
52
|
|
|
* @Assert\NotBlank |
53
|
|
|
*/ |
54
|
|
|
private $value; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Section of the setting. |
58
|
|
|
* |
59
|
|
|
* @ORM\Column(type="string", length=60, nullable=false) |
60
|
|
|
* @Assert\NotNull |
61
|
|
|
* @Assert\NotBlank |
62
|
|
|
*/ |
63
|
|
|
private $section; |
64
|
|
|
|
65
|
6 |
|
/** |
66
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="settings") |
67
|
6 |
|
* @ApiProperty(readable=false) |
68
|
|
|
*/ |
69
|
|
|
protected $user; |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get name. |
74
|
|
|
* |
75
|
|
|
* @inheritDoc |
76
|
|
|
*/ |
77
|
49 |
|
public function getName() |
78
|
|
|
{ |
79
|
49 |
|
return $this->name; |
80
|
|
|
} |
81
|
49 |
|
|
82
|
|
|
/** |
83
|
|
|
* Sets the name of setting. |
84
|
|
|
* |
85
|
|
|
* @param mixed $name the name |
86
|
|
|
* |
87
|
|
|
* @return self |
88
|
|
|
*/ |
89
|
5 |
|
public function setName($name) |
90
|
|
|
{ |
91
|
5 |
|
$this->name = $name; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Get key. |
98
|
|
|
* |
99
|
|
|
* @inheritDoc |
100
|
|
|
*/ |
101
|
49 |
|
public function getKey() |
102
|
|
|
{ |
103
|
49 |
|
return $this->key; |
104
|
|
|
} |
105
|
49 |
|
|
106
|
|
|
/** |
107
|
|
|
* Sets the key of setting. |
108
|
|
|
* |
109
|
|
|
* @param mixed $key the key |
110
|
|
|
* |
111
|
|
|
* @return self |
112
|
|
|
*/ |
113
|
|
|
public function setKey($key) |
114
|
5 |
|
{ |
115
|
|
|
$this->key = $key; |
116
|
5 |
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get value. |
123
|
|
|
* |
124
|
|
|
* @inheritDoc |
125
|
|
|
*/ |
126
|
49 |
|
public function getValue() |
127
|
|
|
{ |
128
|
49 |
|
return $this->value; |
129
|
|
|
} |
130
|
49 |
|
|
131
|
|
|
/** |
132
|
|
|
* Sets the value of setting. |
133
|
|
|
* |
134
|
|
|
* @param mixed $value the value |
135
|
|
|
* |
136
|
|
|
* @return self |
137
|
|
|
*/ |
138
|
5 |
|
public function setValue($value) |
139
|
|
|
{ |
140
|
5 |
|
$this->value = $value; |
141
|
|
|
|
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Get section. |
147
|
|
|
* |
148
|
|
|
* @inheritDoc |
149
|
|
|
*/ |
150
|
49 |
|
public function getSection() |
151
|
|
|
{ |
152
|
49 |
|
return $this->section; |
153
|
|
|
} |
154
|
49 |
|
|
155
|
|
|
/** |
156
|
|
|
* Sets the value of section. |
157
|
|
|
* |
158
|
|
|
* @param mixed $section the section |
159
|
|
|
* |
160
|
|
|
* @return self |
161
|
|
|
*/ |
162
|
|
|
public function setSection($section) |
163
|
|
|
{ |
164
|
|
|
$this->section = $section; |
165
|
|
|
|
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Gets the value of user. |
171
|
|
|
* |
172
|
|
|
* @return mixed |
173
|
|
|
*/ |
174
|
49 |
|
public function getUser() |
175
|
|
|
{ |
176
|
49 |
|
return $this->user; |
177
|
|
|
} |
178
|
49 |
|
|
179
|
|
|
/** |
180
|
|
|
* Sets the value of user. |
181
|
|
|
* |
182
|
|
|
* @param mixed $user the user |
183
|
|
|
* |
184
|
|
|
* @return self |
185
|
|
|
*/ |
186
|
|
|
public function setUser($user) |
187
|
|
|
{ |
188
|
|
|
$this->user = $user; |
189
|
|
|
|
190
|
|
|
return $this; |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
|