1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainFoundation\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Loevgaard\DandomainDateTime\DateTimeImmutable; |
7
|
|
|
use Loevgaard\DandomainFoundation\Entity\Generated\PeriodInterface; |
8
|
|
|
use Loevgaard\DandomainFoundation\Entity\Generated\PeriodTrait; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @ORM\Entity() |
12
|
|
|
* @ORM\Table(name="loevgaard_dandomain_periods") |
13
|
|
|
*/ |
14
|
|
|
class Period extends AbstractEntity implements PeriodInterface |
15
|
|
|
{ |
16
|
|
|
use PeriodTrait; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var int |
20
|
|
|
* |
21
|
|
|
* @ORM\Id |
22
|
|
|
* @ORM\GeneratedValue |
23
|
|
|
* @ORM\Column(type="integer") |
24
|
|
|
**/ |
25
|
|
|
protected $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var int |
29
|
|
|
* |
30
|
|
|
* @ORM\Column(type="string", unique=true) |
31
|
|
|
*/ |
32
|
|
|
protected $externalId; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var bool|null |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(nullable=true, type="boolean") |
38
|
|
|
*/ |
39
|
|
|
protected $disabled; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var \DateTimeImmutable|null |
43
|
|
|
* |
44
|
|
|
* @ORM\Column(nullable=true, type="datetime_immutable") |
45
|
|
|
*/ |
46
|
|
|
protected $endDate; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var \DateTimeImmutable|null |
50
|
|
|
* |
51
|
|
|
* @ORM\Column(nullable=true, type="datetime_immutable") |
52
|
|
|
*/ |
53
|
|
|
protected $startDate; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string|null |
57
|
|
|
* |
58
|
|
|
* @ORM\Column(nullable=true, type="string", length=191) |
59
|
|
|
*/ |
60
|
|
|
protected $title; |
61
|
|
|
|
62
|
|
|
public function hydrate(array $data) |
63
|
|
|
{ |
64
|
|
|
if ($data['startDate']) { |
65
|
|
|
$data['startDate'] = DateTimeImmutable::createFromJson($data['startDate']); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if ($data['endDate']) { |
69
|
|
|
$data['endDate'] = DateTimeImmutable::createFromJson($data['endDate']); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
parent::hydrate($data); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return int |
77
|
|
|
*/ |
78
|
|
|
public function getId(): int |
79
|
|
|
{ |
80
|
|
|
return (int)$this->id; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param int $id |
85
|
|
|
* @return Period |
86
|
|
|
*/ |
87
|
|
|
public function setId(int $id) |
88
|
|
|
{ |
89
|
|
|
$this->id = $id; |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return int |
95
|
|
|
*/ |
96
|
|
|
public function getExternalId(): int |
97
|
|
|
{ |
98
|
|
|
return (int)$this->externalId; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param int $externalId |
103
|
|
|
* @return Period |
104
|
|
|
*/ |
105
|
|
|
public function setExternalId(int $externalId) |
106
|
|
|
{ |
107
|
|
|
$this->externalId = $externalId; |
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return bool|null |
113
|
|
|
*/ |
114
|
|
|
public function getDisabled() |
115
|
|
|
{ |
116
|
|
|
return $this->disabled; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param bool|null $disabled |
121
|
|
|
* @return Period |
122
|
|
|
*/ |
123
|
|
|
public function setDisabled($disabled) |
124
|
|
|
{ |
125
|
|
|
$this->disabled = $disabled; |
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return \DateTimeImmutable|null |
131
|
|
|
*/ |
132
|
|
|
public function getEndDate() |
133
|
|
|
{ |
134
|
|
|
return $this->endDate; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param \DateTimeImmutable|null $endDate |
139
|
|
|
* @return Period |
140
|
|
|
*/ |
141
|
|
|
public function setEndDate($endDate) |
142
|
|
|
{ |
143
|
|
|
$this->endDate = $endDate; |
144
|
|
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return \DateTimeImmutable|null |
149
|
|
|
*/ |
150
|
|
|
public function getStartDate() |
151
|
|
|
{ |
152
|
|
|
return $this->startDate; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param \DateTimeImmutable|null $startDate |
157
|
|
|
* @return Period |
158
|
|
|
*/ |
159
|
|
|
public function setStartDate($startDate) |
160
|
|
|
{ |
161
|
|
|
$this->startDate = $startDate; |
162
|
|
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return null|string |
167
|
|
|
*/ |
168
|
|
|
public function getTitle() |
169
|
|
|
{ |
170
|
|
|
return $this->title; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param null|string $title |
175
|
|
|
* @return Period |
176
|
|
|
*/ |
177
|
|
|
public function setTitle($title) |
178
|
|
|
{ |
179
|
|
|
$this->title = $title; |
180
|
|
|
return $this; |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
|