|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the TheAlternativeZurich/events project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Florian Moser <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace App\Entity\Traits; |
|
13
|
|
|
|
|
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
15
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
16
|
|
|
|
|
17
|
|
|
/* |
|
18
|
|
|
* Attendee information |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
trait ContactInformationTrait |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var string|null |
|
25
|
|
|
* |
|
26
|
|
|
* @ORM\Column(type="text") |
|
27
|
|
|
*/ |
|
28
|
|
|
private $givenName; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var string|null |
|
32
|
|
|
* |
|
33
|
|
|
* @ORM\Column(type="text") |
|
34
|
|
|
*/ |
|
35
|
|
|
private $familyName; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string|null |
|
39
|
|
|
* |
|
40
|
|
|
* @ORM\Column(type="text") |
|
41
|
|
|
*/ |
|
42
|
|
|
private $phone; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var string|null |
|
46
|
|
|
* |
|
47
|
|
|
* @ORM\Column(type="text") |
|
48
|
|
|
*/ |
|
49
|
|
|
private $email; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var string|null |
|
53
|
|
|
* |
|
54
|
|
|
* @ORM\Column(type="text") |
|
55
|
|
|
*/ |
|
56
|
|
|
private $streetAddress; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var int|null |
|
60
|
|
|
* |
|
61
|
|
|
* @ORM\Column(type="integer") |
|
62
|
|
|
*/ |
|
63
|
|
|
private $postalCode; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @var string|null |
|
67
|
|
|
* |
|
68
|
|
|
* @ORM\Column(type="text") |
|
69
|
|
|
*/ |
|
70
|
|
|
private $locality; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @var string|null |
|
74
|
|
|
* |
|
75
|
|
|
* @ORM\Column(type="string", nullable=true) |
|
76
|
|
|
*/ |
|
77
|
|
|
private $canton; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @var string |
|
81
|
|
|
* |
|
82
|
|
|
* @ORM\Column(type="text", nullable=true) |
|
83
|
|
|
* @Assert\Country() |
|
84
|
|
|
*/ |
|
85
|
|
|
private $country = 'CH'; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param ContactInformationTrait $other |
|
89
|
|
|
*/ |
|
90
|
|
|
protected function fromOtherContactInformation($other) |
|
91
|
|
|
{ |
|
92
|
|
|
$this->givenName = $other->getGivenName(); |
|
93
|
|
|
$this->familyName = $other->getFamilyName(); |
|
94
|
|
|
$this->phone = $other->getPhone(); |
|
95
|
|
|
$this->email = $other->getEmail(); |
|
96
|
|
|
$this->streetAddress = $other->getStreetAddress(); |
|
97
|
|
|
$this->postalCode = $other->getPostalCode(); |
|
98
|
|
|
$this->locality = $other->getLocality(); |
|
99
|
|
|
$this->canton = $other->getCanton(); |
|
100
|
|
|
$this->country = $other->getCountry(); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function getGivenName(): ?string |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->givenName; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function setGivenName(?string $givenName): void |
|
109
|
|
|
{ |
|
110
|
|
|
$this->givenName = $givenName; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function getFamilyName(): ?string |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->familyName; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function setFamilyName(?string $familyName): void |
|
119
|
|
|
{ |
|
120
|
|
|
$this->familyName = $familyName; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function getPhone(): ?string |
|
124
|
|
|
{ |
|
125
|
|
|
return $this->phone; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
public function setPhone(?string $phone): void |
|
129
|
|
|
{ |
|
130
|
|
|
$this->phone = $phone; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
public function getEmail(): ?string |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->email; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
public function setEmail(?string $email): void |
|
139
|
|
|
{ |
|
140
|
|
|
$this->email = $email; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function getStreetAddress(): ?string |
|
144
|
|
|
{ |
|
145
|
|
|
return $this->streetAddress; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
public function setStreetAddress(?string $streetAddress): void |
|
149
|
|
|
{ |
|
150
|
|
|
$this->streetAddress = $streetAddress; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
public function getPostalCode(): ?int |
|
154
|
|
|
{ |
|
155
|
|
|
return $this->postalCode; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
public function setPostalCode(?int $postalCode): void |
|
159
|
|
|
{ |
|
160
|
|
|
$this->postalCode = $postalCode; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
public function getLocality(): ?string |
|
164
|
|
|
{ |
|
165
|
|
|
return $this->locality; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
public function setLocality(?string $locality): void |
|
169
|
|
|
{ |
|
170
|
|
|
$this->locality = $locality; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
public function getCanton(): ?string |
|
174
|
|
|
{ |
|
175
|
|
|
return $this->canton; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
public function setCanton(?string $canton): void |
|
179
|
|
|
{ |
|
180
|
|
|
$this->canton = $canton; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
public function getCountry(): string |
|
184
|
|
|
{ |
|
185
|
|
|
return $this->country; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
public function setCountry(string $country): void |
|
189
|
|
|
{ |
|
190
|
|
|
$this->country = $country; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* returns all non-empty address lines. |
|
195
|
|
|
* |
|
196
|
|
|
* @return string[] |
|
197
|
|
|
*/ |
|
198
|
|
|
public function getAddressLines() |
|
199
|
|
|
{ |
|
200
|
|
|
$res = explode("\n", $this->getStreetAddress()); |
|
201
|
|
|
$prefix = ''; |
|
202
|
|
|
if (mb_strlen($this->getCountry()) > 0) { |
|
203
|
|
|
$prefix = $this->getCountry().((mb_strlen($this->getPostalCode()) > 0) ? '-' : ' '); |
|
204
|
|
|
} |
|
205
|
|
|
if (mb_strlen($this->getPostalCode()) > 0) { |
|
206
|
|
|
$prefix .= $this->getPostalCode().' '; |
|
207
|
|
|
} |
|
208
|
|
|
if (mb_strlen($this->getLocality()) > 0) { |
|
209
|
|
|
$prefix .= $this->getLocality().' '; |
|
210
|
|
|
} |
|
211
|
|
|
if (mb_strlen($this->getCanton()) > 0) { |
|
212
|
|
|
$prefix .= $this->getCanton().' '; |
|
213
|
|
|
} |
|
214
|
|
|
$res[] = trim($prefix); |
|
215
|
|
|
|
|
216
|
|
|
$result = []; |
|
217
|
|
|
foreach ($res as $entry) { |
|
218
|
|
|
if (mb_strlen($entry) > 0) { |
|
219
|
|
|
$result[] = $entry; |
|
220
|
|
|
} |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
return $result; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
public function getName() |
|
227
|
|
|
{ |
|
228
|
|
|
return $this->givenName.' '.$this->familyName; |
|
229
|
|
|
} |
|
230
|
|
|
} |
|
231
|
|
|
|