User.php 7.09 KB
Newer Older
Ole Hartwig's avatar
Ole Hartwig committed
1
<?php
2
declare(strict_types=1);
3
namespace T3o\Certifications\Domain\Model;
Ole Hartwig's avatar
Ole Hartwig committed
4 5

/**
Andreas Wolf's avatar
Andreas Wolf committed
6
 * This file is part of the TYPO3 CMS project.
Ole Hartwig's avatar
Ole Hartwig committed
7
 *
Andreas Wolf's avatar
Andreas Wolf committed
8 9 10
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
Ole Hartwig's avatar
Ole Hartwig committed
11
 *
Andreas Wolf's avatar
Andreas Wolf committed
12 13
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
Ole Hartwig's avatar
Ole Hartwig committed
14
 *
Andreas Wolf's avatar
Andreas Wolf committed
15
 * The TYPO3 project - inspiring people to share!
Ole Hartwig's avatar
Ole Hartwig committed
16
 */
17 18 19 20 21

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class User extends AbstractEntity
22 23 24 25
{
    /**
     * @var string
     */
26
    protected $firstName = '';
27 28 29 30

    /**
     * @var string
     */
31
    protected $middleName = '';
32 33 34 35

    /**
     * @var string
     */
36
    protected $lastName = '';
37 38 39 40 41 42 43 44 45 46 47

    /**
     * @var string
     */
    protected $country = '';

    /**
     * certReason
     *
     * @var string
     */
48
    protected $certReason = '';
49 50 51 52 53 54

    /**
     * publicEmailAddress
     *
     * @var boolean
     */
55
    protected $publicEmailAddress = false;
56 57 58 59 60 61

    /**
     * email
     *
     * @var string
     */
62
    protected $email = '';
63 64 65 66

    /**
     * certificates
     *
67
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Certifications\Domain\Model\Certificate>
68
     */
69
    protected $certificates = null;
70 71 72 73

    /**
     * feUser
     *
74
     * @var User
75
     */
76
    protected $feUser = null;
Sascha Schmidt's avatar
Sascha Schmidt committed
77

78 79 80 81 82
    /**
     * twitter
     *
     * @var string
     */
83
    protected $twitter = '';
84 85 86 87 88 89

    /**
     * publicTwitter
     *
     * @var boolean
     */
90
    protected $publicTwitter = false;
91

92
    /**
93 94 95
     * __construct
     *
     * @return void
96
     */
97
    public function __construct()
98
    {
99 100 101 102 103 104 105 106 107
        $this->initStorageObjects();
    }

    /**
     * @return void
     */
    protected function initStorageObjects()
    {
        $this->certificates = new ObjectStorage();
108 109 110 111 112
    }

    /**
     * @return string
     */
113
    public function getCountry(): string
114 115 116 117 118
    {
        return $this->country;
    }

    /**
119
     * @param string $country
120
     */
121
    public function setCountry(string $country): void
122
    {
123
        $this->country = $country;
124 125 126 127 128
    }

    /**
     * @return string
     */
129
    public function getFirstName(): string
130 131 132 133 134
    {
        return $this->firstName;
    }

    /**
135
     * @param string $firstName
136
     */
137
    public function setFirstName(string $firstName): void
138
    {
139
        $this->firstName = $firstName;
140 141 142 143 144
    }

    /**
     * @return string
     */
145
    public function getLastName(): string
146 147 148 149 150
    {
        return $this->lastName;
    }

    /**
151
     * @param string $lastName
152
     */
153
    public function setLastName(string $lastName): void
154
    {
155
        $this->lastName = $lastName;
156 157 158 159 160
    }

    /**
     * @return string
     */
161
    public function getMiddleName(): string
162 163 164 165 166
    {
        return $this->middleName;
    }

    /**
167
     * @param string $middleName
168
     */
169
    public function setMiddleName(string $middleName): void
170
    {
171
        $this->middleName = $middleName;
172 173 174 175 176
    }

    /**
     * Adds a Certificate
     *
177
     * @param \T3o\Certifications\Domain\Model\Certificate $certificate
178 179
     * @return void
     */
180
    public function addCertificate(Certificate $certificate): void
181 182 183 184 185 186 187
    {
        $this->certificates->attach($certificate);
    }

    /**
     * Removes a Certificate
     *
188
     * @param \T3o\Certifications\Domain\Model\Certificate $certificateToRemove The Certificate to be removed
189 190
     * @return void
     */
191
    public function removeCertificate(Certificate $certificateToRemove): void
192 193 194 195 196 197 198
    {
        $this->certificates->detach($certificateToRemove);
    }

    /**
     * Returns the certificates
     *
199
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Certifications\Domain\Model\Certificate> $certificates
200
     */
201
    public function getCertificates(): ObjectStorage
202 203 204 205 206 207 208
    {
        return $this->certificates;
    }

    /**
     * Sets the certificates
     *
209
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Certifications\Domain\Model\Certificate> $certificates
210 211
     * @return void
     */
212
    public function setCertificates(ObjectStorage $certificates): void
213 214 215 216 217 218 219 220
    {
        $this->certificates = $certificates;
    }

    /**
     * getFeUser
     * Returns the linked frontend user
     *
221
     * @return User $feUser
222
     */
223
    public function getFeUser(): User
224 225 226 227 228 229 230 231
    {
        return $this->feUser;
    }

    /**
     * setFeUser
     * Sets the frontend user
     *
232
     * @param User $feUser
233 234
     * @return void
     */
235
    public function setFeUser(User $feUser): void
236 237 238 239 240 241 242 243 244
    {
        $this->feUser = $feUser;
    }

    /**
     * Returns the certReason
     *
     * @return string $certReason
     */
245
    public function getCertReason(): string
246 247 248 249 250 251 252 253 254 255
    {
        return $this->certReason;
    }

    /**
     * Sets the certReason
     *
     * @param string $certReason
     * @return void
     */
256
    public function setCertReason(string $certReason): void
257 258 259 260 261
    {
        $this->certReason = $certReason;
    }

    /**
262 263 264
     * isPublicInformationAvailable
     * Returns TRUE if there is at least either a public
     * email adress or a public twitter handle
265
     *
266
     * @return bool
267
     */
268
    public function isPublicInformationAvailable(): bool
269
    {
270
        return ($this->isPublicEmailAddress() && $this->getEmail()) || ($this->isPublicTwitter() && $this->getTwitter());
271 272 273
    }

    /**
274
     * Returns the boolean state of publicEmailAddress
275
     *
276
     * @return boolean
277
     */
278
    public function isPublicEmailAddress(): bool
279
    {
280
        return $this->getPublicEmailAddress();
281 282 283 284 285 286 287
    }

    /**
     * Returns the publicEmailAddress
     *
     * @return boolean $publicEmailAddress
     */
288
    public function getPublicEmailAddress(): bool
289 290 291 292 293 294 295 296 297 298
    {
        return $this->publicEmailAddress;
    }

    /**
     * Sets the publicEmailAddress
     *
     * @param boolean $publicEmailAddress
     * @return void
     */
299
    public function setPublicEmailAddress(bool $publicEmailAddress): void
300 301 302 303 304
    {
        $this->publicEmailAddress = $publicEmailAddress;
    }

    /**
305
     * getEmail
306
     *
307
     * @return string $email
308
     */
309
    public function getEmail(): string
310
    {
311
        return $this->email;
312 313 314
    }

    /**
315
     * setEmail
316
     *
317 318
     * @param string $email
     * @return void
319
     */
320
    public function setEmail(string $email = ''): void
321
    {
322
        $this->email = $email;
323 324 325
    }

    /**
326 327 328 329
     * isPublicTwitter
     * Return the boolean state of publicTwitter
     *
     * @return bool
330
     */
331
    public function isPublicTwitter(): bool
332
    {
333
        return $this->getPublicTwitter();
334 335 336 337 338
    }

    /**
     * @return boolean
     */
339
    public function getPublicTwitter(): bool
340 341 342 343 344
    {
        return $this->publicTwitter;
    }

    /**
345
     * @param boolean $publicTwitter
346
     */
347
    public function setPublicTwitter(bool $publicTwitter): void
348
    {
349
        $this->publicTwitter = $publicTwitter;
350 351 352
    }

    /**
353
     * @return string
354
     */
355
    public function getTwitter(): string
356
    {
357
        return $this->twitter;
358 359 360
    }

    /**
361
     * @param string $twitter
362
     */
363
    public function setTwitter(string $twitter): void
364
    {
365
        $this->twitter = $twitter;
366
    }
Ole Hartwig's avatar
Ole Hartwig committed
367
}
368

369
?>