1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
4
|
|
|
|
5
|
|
|
namespace Chamilo\CoreBundle\Entity; |
6
|
|
|
|
7
|
|
|
use Chamilo\CoreBundle\Traits\TimestampableTypedEntity; |
8
|
|
|
use Chamilo\UserBundle\Entity\User; |
9
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
10
|
|
|
use Doctrine\Common\Collections\Collection; |
11
|
|
|
use Doctrine\ORM\Mapping as ORM; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @ORM\Table(name="agenda_event_invitation") |
15
|
|
|
* Add @ to the next lineactivating the agenda_collective_invitations configuration setting. |
16
|
|
|
* ORM\Entity() |
17
|
|
|
*/ |
18
|
|
|
class AgendaEventInvitation |
19
|
|
|
{ |
20
|
|
|
use TimestampableTypedEntity; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var int |
24
|
|
|
* |
25
|
|
|
* @ORM\Id() |
26
|
|
|
* @ORM\Column(type="bigint") |
27
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
28
|
|
|
*/ |
29
|
|
|
protected $id; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var Collection<int, AgendaEventInvitee> |
33
|
|
|
* |
34
|
|
|
* @ORM\OneToMany(targetEntity="AgendaEventInvitee", mappedBy="invitation", cascade={"persist", "remove"}, orphanRemoval=true) |
35
|
|
|
*/ |
36
|
|
|
protected $invitees; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var User |
40
|
|
|
* |
41
|
|
|
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User", inversedBy="resourceNodes") |
42
|
|
|
* @ORM\JoinColumn(name="creator_id", referencedColumnName="id", nullable=true, onDelete="CASCADE") |
43
|
|
|
*/ |
44
|
|
|
protected $creator; |
45
|
|
|
|
46
|
|
|
public function __construct() |
47
|
|
|
{ |
48
|
|
|
$this->invitees = new ArrayCollection(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getId(): int |
52
|
|
|
{ |
53
|
|
|
return $this->id; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getInvitees(): Collection |
57
|
|
|
{ |
58
|
|
|
return $this->invitees; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function setInvitees(Collection $invitees): AgendaEventInvitation |
62
|
|
|
{ |
63
|
|
|
$this->invitees = $invitees; |
64
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function addInvitee(AgendaEventInvitee $invitee): AgendaEventInvitation |
69
|
|
|
{ |
70
|
|
|
$invitee->setInvitation($this); |
71
|
|
|
$this->invitees->add($invitee); |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function removeInviteeUser(User $user): AgendaEventInvitation |
77
|
|
|
{ |
78
|
|
|
/** @var AgendaEventInvitee $invitee */ |
79
|
|
|
$invitee = $this |
80
|
|
|
->invitees |
81
|
|
|
->filter(function (AgendaEventInvitee $invitee) use ($user) { |
82
|
|
|
return $invitee->getUser() === $user; |
83
|
|
|
}) |
84
|
|
|
->first(); |
85
|
|
|
|
86
|
|
|
if ($invitee) { |
|
|
|
|
87
|
|
|
$this->invitees->removeElement($invitee); |
88
|
|
|
$invitee->setInvitation(null); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getCreator(): User |
95
|
|
|
{ |
96
|
|
|
return $this->creator; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function setCreator(User $creator): AgendaEventInvitation |
100
|
|
|
{ |
101
|
|
|
$this->creator = $creator; |
102
|
|
|
|
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|