mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
work on create calendar
This commit is contained in:
@@ -172,6 +172,29 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addUser(User $user): self
|
||||
{
|
||||
if (!$this->getUsers()->contains($user)) {
|
||||
$this->addInvite((new Invite())->setUser($user));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeUser(User $user): self
|
||||
{
|
||||
if (!$this->getUsers()->contains($user)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$invite = $this->invites
|
||||
->filter(function (Invite $invite) use ($user) { return $invite->getUser() === $user; })
|
||||
->first();
|
||||
$this->removeInvite($invite);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addPerson(Person $person): self
|
||||
{
|
||||
$this->persons[] = $person;
|
||||
@@ -309,14 +332,12 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->getProfessionals();
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
/**
|
||||
* @return Collection|User[]
|
||||
*/
|
||||
public function getUsers(): Collection
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function getusers(): Collection
|
||||
{
|
||||
return $this->getInvites(); //TODO get users of the invite
|
||||
return $this->getInvites()->map(function (Invite $i) { return $i->getUser(); });
|
||||
}
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
@@ -335,7 +356,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
public function removeInvite(Invite $invite): self
|
||||
{
|
||||
$this->invites->removeElement($invite);
|
||||
if ($this->invites->removeElement($invite)) {
|
||||
$invite->setCalendar(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user