1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @author Rafał Muszyński <[email protected]> |
5
|
|
|
* @copyright 2015 Sourcefabric z.ú. |
6
|
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.txt |
7
|
|
|
*/ |
8
|
|
|
namespace Newscoop\PaywallBundle\Entity; |
9
|
|
|
|
10
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
11
|
|
|
use Doctrine\ORM\Mapping as ORM; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Discount entity. |
15
|
|
|
* |
16
|
|
|
* @ORM\Entity(repositoryClass="Newscoop\PaywallBundle\Entity\Repository\DiscountRepository") |
17
|
|
|
* @ORM\Table(name="plugin_paywall_discount") |
18
|
|
|
*/ |
19
|
|
|
class Discount implements DiscountInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @ORM\Id |
23
|
|
|
* @ORM\GeneratedValue |
24
|
|
|
* @ORM\Column(type="integer", name="id") |
25
|
|
|
* |
26
|
|
|
* @var int |
27
|
|
|
*/ |
28
|
|
|
protected $id; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @ORM\Column(type="string", name="name", length=100) |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $name; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @ORM\Column(type="string", name="description") |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $description; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @ORM\OneToMany(targetEntity="Duration", mappedBy="discount") |
46
|
|
|
* |
47
|
|
|
* @var ArrayCollection |
48
|
|
|
*/ |
49
|
|
|
protected $durations; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @ORM\Column(type="string", name="type") |
53
|
|
|
* |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
protected $type; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @ORM\Column(type="float", scale=3, name="value") |
60
|
|
|
* |
61
|
|
|
* @var float |
62
|
|
|
*/ |
63
|
|
|
protected $value; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @ORM\Column(type="boolean", name="count_based") |
67
|
|
|
* |
68
|
|
|
* @var bool |
69
|
|
|
*/ |
70
|
|
|
protected $countBased = false; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @ORM\Column(type="datetime", name="updated_at", nullable=true) |
74
|
|
|
* |
75
|
|
|
* @var \DateTime |
76
|
|
|
*/ |
77
|
|
|
protected $updatedAt; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @ORM\Column(type="datetime", name="created_at") |
81
|
|
|
* |
82
|
|
|
* @var \DateTime |
83
|
|
|
*/ |
84
|
|
|
protected $createdAt; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Constructor. |
88
|
|
|
*/ |
89
|
|
|
public function __construct() |
90
|
|
|
{ |
91
|
|
|
$this->durations = new ArrayCollection(); |
92
|
|
|
$this->createdAt = new \DateTime(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Gets the value of id. |
97
|
|
|
* |
98
|
|
|
* @return int |
99
|
|
|
*/ |
100
|
|
|
public function getId() |
101
|
|
|
{ |
102
|
|
|
return $this->id; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Sets the value of id. |
107
|
|
|
* |
108
|
|
|
* @param int $id the id |
109
|
|
|
* |
110
|
|
|
* @return self |
111
|
|
|
*/ |
112
|
|
|
public function setId($id) |
113
|
|
|
{ |
114
|
|
|
$this->id = $id; |
115
|
|
|
|
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Gets the value of name. |
121
|
|
|
* |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
public function getName() |
125
|
|
|
{ |
126
|
|
|
return $this->name; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Sets the value of name. |
131
|
|
|
* |
132
|
|
|
* @param string $name the name |
133
|
|
|
* |
134
|
|
|
* @return self |
135
|
|
|
*/ |
136
|
|
|
public function setName($name) |
137
|
|
|
{ |
138
|
|
|
$this->name = $name; |
139
|
|
|
|
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Gets the value of description. |
145
|
|
|
* |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
public function getDescription() |
149
|
|
|
{ |
150
|
|
|
return $this->description; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Sets the value of description. |
155
|
|
|
* |
156
|
|
|
* @param string $description the description |
157
|
|
|
* |
158
|
|
|
* @return self |
159
|
|
|
*/ |
160
|
|
|
public function setDescription($description) |
161
|
|
|
{ |
162
|
|
|
$this->description = $description; |
163
|
|
|
|
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Gets the value of updatedAt. |
169
|
|
|
* |
170
|
|
|
* @return \DateTime |
171
|
|
|
*/ |
172
|
|
|
public function getUpdatedAt() |
173
|
|
|
{ |
174
|
|
|
return $this->updatedAt; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Sets the value of updatedAt. |
179
|
|
|
* |
180
|
|
|
* @param \DateTime $updatedAt the updated at |
181
|
|
|
* |
182
|
|
|
* @return self |
183
|
|
|
*/ |
184
|
|
|
public function setUpdatedAt(\DateTime $updatedAt) |
185
|
|
|
{ |
186
|
|
|
$this->updatedAt = $updatedAt; |
187
|
|
|
|
188
|
|
|
return $this; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Gets the value of createdAt. |
193
|
|
|
* |
194
|
|
|
* @return \DateTime |
195
|
|
|
*/ |
196
|
|
|
public function getCreatedAt() |
197
|
|
|
{ |
198
|
|
|
return $this->createdAt; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Sets the value of createdAt. |
203
|
|
|
* |
204
|
|
|
* @param \DateTime $createdAt the created at |
205
|
|
|
* |
206
|
|
|
* @return self |
207
|
|
|
*/ |
208
|
|
|
public function setCreatedAt(\DateTime $createdAt) |
209
|
|
|
{ |
210
|
|
|
$this->createdAt = $createdAt; |
211
|
|
|
|
212
|
|
|
return $this; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* {@inheritdoc} |
217
|
|
|
*/ |
218
|
|
|
public function getType() |
219
|
|
|
{ |
220
|
|
|
return $this->type; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* {@inheritdoc} |
225
|
|
|
*/ |
226
|
|
|
public function setType($type) |
227
|
|
|
{ |
228
|
|
|
$this->type = $type; |
229
|
|
|
|
230
|
|
|
return $this; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* {@inheritdoc} |
235
|
|
|
*/ |
236
|
|
|
public function getValue() |
237
|
|
|
{ |
238
|
|
|
return $this->value; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* {@inheritdoc} |
243
|
|
|
*/ |
244
|
|
|
public function setValue($value) |
245
|
|
|
{ |
246
|
|
|
$this->value = $value; |
247
|
|
|
|
248
|
|
|
return $this; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Gets the value of countBased. |
253
|
|
|
* |
254
|
|
|
* @return bool |
255
|
|
|
*/ |
256
|
|
|
public function isCountBased() |
257
|
|
|
{ |
258
|
|
|
return $this->countBased; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* Sets the value of countBased. |
263
|
|
|
* |
264
|
|
|
* @param bool $countBased the count based |
265
|
|
|
* |
266
|
|
|
* @return self |
267
|
|
|
*/ |
268
|
|
|
public function setCountBased($countBased) |
269
|
|
|
{ |
270
|
|
|
$this->countBased = $countBased; |
271
|
|
|
|
272
|
|
|
return $this; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* Gets the value of durations. |
277
|
|
|
* |
278
|
|
|
* @return ArrayCollection |
279
|
|
|
*/ |
280
|
|
|
public function getDurations() |
281
|
|
|
{ |
282
|
|
|
return $this->durations; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* Sets the value of durations. |
287
|
|
|
* |
288
|
|
|
* @param ArrayCollection $durations the durations |
289
|
|
|
* |
290
|
|
|
* @return self |
291
|
|
|
*/ |
292
|
|
|
public function setDurations(ArrayCollection $durations) |
293
|
|
|
{ |
294
|
|
|
$this->durations = $durations; |
295
|
|
|
|
296
|
|
|
return $this; |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
|