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; |
13
|
|
|
|
14
|
|
|
use App\Entity\Base\BaseEntity; |
15
|
|
|
use App\Entity\Traits\ContactInformationTrait; |
16
|
|
|
use App\Entity\Traits\IdTrait; |
17
|
|
|
use App\Entity\Traits\TimeTrait; |
18
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
19
|
|
|
use Doctrine\ORM\Mapping as ORM; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @ORM\Entity() |
23
|
|
|
* @ORM\HasLifecycleCallbacks |
24
|
|
|
*/ |
25
|
|
|
class Registration extends BaseEntity |
26
|
|
|
{ |
27
|
|
|
use IdTrait; |
28
|
|
|
use TimeTrait; |
29
|
|
|
use ContactInformationTrait; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var bool |
33
|
|
|
* |
34
|
|
|
* @ORM\Column(type="boolean") |
35
|
|
|
*/ |
36
|
|
|
private $isOrganizer = false; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var int |
40
|
|
|
* |
41
|
|
|
* @ORM\Column(type="integer") |
42
|
|
|
*/ |
43
|
|
|
private $number; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var Event |
47
|
|
|
* |
48
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Event", inversedBy="registrations") |
49
|
|
|
*/ |
50
|
|
|
private $event; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var User |
54
|
|
|
* |
55
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="registrations") |
56
|
|
|
*/ |
57
|
|
|
private $user; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var Participation[]|ArrayCollection |
61
|
|
|
* |
62
|
|
|
* @ORM\OneToMany (targetEntity="App\Entity\Participation", mappedBy="registration") |
63
|
|
|
*/ |
64
|
|
|
private $participations; |
65
|
|
|
|
66
|
|
|
public function __construct() |
67
|
|
|
{ |
68
|
|
|
$this->participations = new ArrayCollection(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public static function createFromUser(Event $event, User $user, int $registrationNumber, bool $isOrganizer = false) |
72
|
|
|
{ |
73
|
|
|
$registration = new Registration(); |
74
|
|
|
$registration->event = $event; |
75
|
|
|
$registration->user = $user; |
76
|
|
|
$registration->number = $registrationNumber; |
77
|
|
|
$registration->isOrganizer = $isOrganizer; |
78
|
|
|
$registration->fromOtherContactInformation($user); |
79
|
|
|
|
80
|
|
|
return $registration; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getIsOrganizer(): bool |
84
|
|
|
{ |
85
|
|
|
return $this->isOrganizer; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function setIsOrganizer(bool $isOrganizer): void |
89
|
|
|
{ |
90
|
|
|
$this->isOrganizer = $isOrganizer; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return Event |
95
|
|
|
*/ |
96
|
|
|
public function getEvent() |
97
|
|
|
{ |
98
|
|
|
return $this->event; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return User |
103
|
|
|
*/ |
104
|
|
|
public function getUser() |
105
|
|
|
{ |
106
|
|
|
return $this->user; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|