mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,28 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\CalendarBundle\Entity;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\CalendarBundle\Entity\CancelReason;
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="chill_calendar.calendar")
|
||||
@@ -30,24 +33,11 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
*/
|
||||
class Calendar
|
||||
{
|
||||
const STATUS_VALID = 'valid';
|
||||
const STATUS_CANCELED = 'canceled';
|
||||
const STATUS_MOVED = 'moved';
|
||||
public const STATUS_CANCELED = 'canceled';
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private ?int $id;
|
||||
public const STATUS_MOVED = 'moved';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private ?User $user = null;
|
||||
public const STATUS_VALID = 'valid';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
|
||||
@@ -56,42 +46,19 @@ class Calendar
|
||||
private AccompanyingPeriod $accompanyingPeriod;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\Activity")
|
||||
*/
|
||||
private ?User $mainUser;
|
||||
private ?Activity $activity = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
* @ORM\ManyToOne(targetEntity="CalendarRange", inversedBy="calendars")
|
||||
*/
|
||||
private Collection $persons;
|
||||
private ?CalendarRange $calendarRange = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties")
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
* @ORM\ManyToOne(targetEntity="CancelReason")
|
||||
*/
|
||||
private Collection $professionals;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Invite",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_invites")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private Collection $invites;
|
||||
private ?CancelReason $cancelReason = null;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_")
|
||||
@@ -103,38 +70,24 @@ class Calendar
|
||||
* @ORM\Column(type="datetimetz_immutable")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
private ?DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetimetz_immutable")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
private ?int $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Invite",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_invites")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?string $status = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="CancelReason")
|
||||
*/
|
||||
private ?CancelReason $cancelReason = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="CalendarRange", inversedBy="calendars")
|
||||
*/
|
||||
private ?CalendarRange $calendarRange = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\Activity")
|
||||
*/
|
||||
private ?Activity $activity = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
*/
|
||||
private ?bool $sendSMS;
|
||||
private Collection $invites;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
|
||||
@@ -142,6 +95,54 @@ class Calendar
|
||||
*/
|
||||
private ?Location $location = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private ?User $mainUser;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private Collection $persons;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties")
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private Collection $professionals;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
*/
|
||||
private ?bool $sendSMS;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetimetz_immutable")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private ?DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private ?string $status = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private ?User $user = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -151,164 +152,6 @@ class Calendar
|
||||
$this->invites = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getSendSMS(): ?bool
|
||||
{
|
||||
return $this->sendSMS;
|
||||
}
|
||||
|
||||
public function setSendSMS(?bool $sendSMS): self
|
||||
{
|
||||
$this->sendSMS = $sendSMS;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getComment(): CommentEmbeddable
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function setComment(CommentEmbeddable $comment): self
|
||||
{
|
||||
$this->comment = $comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
public function setStartDate(\DateTimeImmutable $startDate): self
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
public function setEndDate(\DateTimeImmutable $endDate): self
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatus(): ?string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus(string $status): self
|
||||
{
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
{
|
||||
return $this->accompanyingPeriod;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
||||
{
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMainUser(): ?User
|
||||
{
|
||||
return $this->mainUser;
|
||||
}
|
||||
|
||||
public function setMainUser(?User $mainUser): self
|
||||
{
|
||||
$this->mainUser = $mainUser;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Person[]
|
||||
*/
|
||||
public function getPersons(): Collection
|
||||
{
|
||||
return $this->persons;
|
||||
}
|
||||
|
||||
public function addPerson(?Person $person): self
|
||||
{
|
||||
if (null !== $person) {
|
||||
$this->persons[] = $person;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePerson(Person $person): self
|
||||
{
|
||||
$this->persons->removeElement($person);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|ThirdParty[]
|
||||
*/
|
||||
public function getProfessionals(): Collection
|
||||
{
|
||||
return $this->professionals;
|
||||
}
|
||||
|
||||
public function addProfessional(?ThirdParty $professional): self
|
||||
{
|
||||
if (null !== $professional) {
|
||||
$this->professionals[] = $professional;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProfessional(ThirdParty $professional): self
|
||||
{
|
||||
$this->professionals->removeElement($professional);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Invite[]
|
||||
*/
|
||||
public function getInvites(): Collection
|
||||
{
|
||||
return $this->invites;
|
||||
}
|
||||
|
||||
public function addInvite(?Invite $invite): self
|
||||
{
|
||||
if (null !== $invite) {
|
||||
@@ -318,35 +161,27 @@ class Calendar
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeInvite(Invite $invite): self
|
||||
public function addPerson(?Person $person): self
|
||||
{
|
||||
$this->invites->removeElement($invite);
|
||||
if (null !== $person) {
|
||||
$this->persons[] = $person;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCancelReason(): ?CancelReason
|
||||
public function addProfessional(?ThirdParty $professional): self
|
||||
{
|
||||
return $this->cancelReason;
|
||||
}
|
||||
|
||||
public function setCancelReason(?CancelReason $cancelReason): self
|
||||
{
|
||||
$this->cancelReason = $cancelReason;
|
||||
if (null !== $professional) {
|
||||
$this->professionals[] = $professional;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCalendarRange(): ?CalendarRange
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
{
|
||||
return $this->calendarRange;
|
||||
}
|
||||
|
||||
public function setCalendarRange(?CalendarRange $calendarRange): self
|
||||
{
|
||||
$this->calendarRange = $calendarRange;
|
||||
|
||||
return $this;
|
||||
return $this->accompanyingPeriod;
|
||||
}
|
||||
|
||||
public function getActivity(): ?Activity
|
||||
@@ -354,24 +189,71 @@ class Calendar
|
||||
return $this->activity;
|
||||
}
|
||||
|
||||
public function setActivity(?Activity $activity): self
|
||||
public function getCalendarRange(): ?CalendarRange
|
||||
{
|
||||
$this->activity = $activity;
|
||||
return $this->calendarRange;
|
||||
}
|
||||
|
||||
return $this;
|
||||
public function getCancelReason(): ?CancelReason
|
||||
{
|
||||
return $this->cancelReason;
|
||||
}
|
||||
|
||||
public function getComment(): CommentEmbeddable
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Invite[]
|
||||
*/
|
||||
public function getInvites(): Collection
|
||||
{
|
||||
return $this->invites;
|
||||
}
|
||||
|
||||
public function getLocation(): ?Location
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function getMainUser(): ?User
|
||||
{
|
||||
return $this->mainUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Person[]
|
||||
*/
|
||||
public function getPersons(): Collection
|
||||
{
|
||||
return $this->persons;
|
||||
}
|
||||
|
||||
public function getPersonsAssociated(): array
|
||||
{
|
||||
if (null !== $this->accompanyingPeriod) {
|
||||
$personsAssociated = [];
|
||||
|
||||
foreach ($this->accompanyingPeriod->getParticipations() as $participation) {
|
||||
if ($this->persons->contains($participation->getPerson())) {
|
||||
$personsAssociated[] = $participation->getPerson();
|
||||
}
|
||||
}
|
||||
|
||||
return $personsAssociated;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -379,22 +261,52 @@ class Calendar
|
||||
{
|
||||
if (null !== $this->accompanyingPeriod) {
|
||||
$personsNotAssociated = [];
|
||||
|
||||
foreach ($this->persons as $person) {
|
||||
if (!in_array($person, $this->getPersonsAssociated())) {
|
||||
$personsNotAssociated[] = $person;
|
||||
$personsNotAssociated[] = $person;
|
||||
}
|
||||
}
|
||||
|
||||
return $personsNotAssociated;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|ThirdParty[]
|
||||
*/
|
||||
public function getProfessionals(): Collection
|
||||
{
|
||||
return $this->professionals;
|
||||
}
|
||||
|
||||
public function getSendSMS(): ?bool
|
||||
{
|
||||
return $this->sendSMS;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
public function getStatus(): ?string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getThirdParties(): Collection
|
||||
{
|
||||
return $this->getProfessionals();
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function getusers(): Collection
|
||||
{
|
||||
return $this->getInvites(); //TODO get users of the invite
|
||||
@@ -414,22 +326,108 @@ class Calendar
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Location|null
|
||||
*/
|
||||
public function getLocation(): ?Location
|
||||
public function removeInvite(Invite $invite): self
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
$this->invites->removeElement($invite);
|
||||
|
||||
/**
|
||||
* @param Location|null $location
|
||||
* @return Calendar
|
||||
*/
|
||||
public function setLocation(?Location $location): Calendar
|
||||
{
|
||||
$this->location = $location;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePerson(Person $person): self
|
||||
{
|
||||
$this->persons->removeElement($person);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProfessional(ThirdParty $professional): self
|
||||
{
|
||||
$this->professionals->removeElement($professional);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
||||
{
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setActivity(?Activity $activity): self
|
||||
{
|
||||
$this->activity = $activity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCalendarRange(?CalendarRange $calendarRange): self
|
||||
{
|
||||
$this->calendarRange = $calendarRange;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCancelReason(?CancelReason $cancelReason): self
|
||||
{
|
||||
$this->cancelReason = $cancelReason;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setComment(CommentEmbeddable $comment): self
|
||||
{
|
||||
$this->comment = $comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEndDate(DateTimeImmutable $endDate): self
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLocation(?Location $location): Calendar
|
||||
{
|
||||
$this->location = $location;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMainUser(?User $mainUser): self
|
||||
{
|
||||
$this->mainUser = $mainUser;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSendSMS(?bool $sendSMS): self
|
||||
{
|
||||
$this->sendSMS = $sendSMS;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStartDate(DateTimeImmutable $startDate): self
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStatus(string $status): self
|
||||
{
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user