mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
send first calendar on ms graph
This commit is contained in:
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\Entity;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
@@ -38,7 +37,7 @@ use function in_array;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="chill_calendar.calendar", indexes={@ORM\Index(name="idx_calendar_remote", columns={"remoteId"})}))
|
||||
* @ORM\Entity(repositoryClass=CalendarRepository::class)
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
@@ -54,6 +53,24 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
public const STATUS_VALID = 'valid';
|
||||
|
||||
/**
|
||||
* a list of invite which have been added during this session.
|
||||
*
|
||||
* @var array|Invite[]
|
||||
*/
|
||||
public array $newInvites = [];
|
||||
|
||||
/**
|
||||
* a list of invite which have been removed during this session.
|
||||
*
|
||||
* @var array|Invite[]
|
||||
*/
|
||||
public array $oldInvites = [];
|
||||
|
||||
public ?CalendarRange $previousCalendarRange = null;
|
||||
|
||||
public ?User $previousMainUser = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
|
||||
* @Serializer\Groups({"read"})
|
||||
@@ -118,7 +135,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @Serializer\Groups({"calendar:read", "read"})
|
||||
*/
|
||||
private ?User $mainUser;
|
||||
private ?User $mainUser = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(
|
||||
@@ -162,6 +179,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
$this->invites = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Use {@link (Calendar::addUser)} instead
|
||||
*/
|
||||
public function addInvite(Invite $invite): self
|
||||
{
|
||||
if ($invite->getCalendar() instanceof Calendar && $invite->getCalendar() !== $this) {
|
||||
@@ -169,6 +189,8 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
}
|
||||
|
||||
$this->invites[] = $invite;
|
||||
$this->newInvites[] = $invite;
|
||||
|
||||
$invite->setCalendar($this);
|
||||
|
||||
return $this;
|
||||
@@ -338,6 +360,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->getInvites()->map(static function (Invite $i) { return $i->getUser(); });
|
||||
}
|
||||
|
||||
public function hasCalendarRange(): bool
|
||||
{
|
||||
return null !== $this->calendarRange;
|
||||
}
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('startDate', new NotBlank());
|
||||
@@ -352,10 +379,14 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Use {@link (Calendar::removeUser)} instead
|
||||
*/
|
||||
public function removeInvite(Invite $invite): self
|
||||
{
|
||||
if ($this->invites->removeElement($invite)) {
|
||||
$invite->setCalendar(null);
|
||||
$this->oldInvites[] = $invite;
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -405,8 +436,15 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
public function setCalendarRange(?CalendarRange $calendarRange): self
|
||||
{
|
||||
$this->calendarRange = $calendarRange;
|
||||
if ($this->calendarRange !== $calendarRange) {
|
||||
$this->previousCalendarRange = $this->calendarRange;
|
||||
|
||||
if (null !== $this->previousCalendarRange) {
|
||||
$this->previousCalendarRange->setCalendar(null);
|
||||
}
|
||||
}
|
||||
|
||||
$this->calendarRange = $calendarRange;
|
||||
$this->calendarRange->setCalendar($this);
|
||||
|
||||
return $this;
|
||||
@@ -442,6 +480,10 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
public function setMainUser(?User $mainUser): self
|
||||
{
|
||||
if ($this->mainUser !== $mainUser) {
|
||||
$this->previousMainUser = $this->mainUser;
|
||||
}
|
||||
|
||||
$this->mainUser = $mainUser;
|
||||
|
||||
return $this;
|
||||
|
Reference in New Issue
Block a user