recreate calendar range when an event is deleted

This commit is contained in:
2022-07-01 13:43:30 +02:00
parent 0276ec1bc7
commit 87403e509f
9 changed files with 160 additions and 19 deletions

View File

@@ -0,0 +1,73 @@
<?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.
*/
declare(strict_types=1);
namespace Chill\CalendarBundle\Messenger\Message;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\MainBundle\Entity\User;
class CalendarRemovedMessage
{
private ?int $byUserId = null;
private int $calendarUserId;
private array $remoteAttributes;
private string $remoteId;
private ?int $associatedCalendarRangeId = null;
public function __construct(Calendar $calendar, ?User $byUser)
{
$this->remoteId = $calendar->getRemoteId();
$this->remoteAttributes = $calendar->getRemoteAttributes();
$this->calendarUserId = $calendar->getMainUser()->getId();
if ($calendar->hasCalendarRange()) {
$this->associatedCalendarRangeId = $calendar->getCalendarRange()->getId();
}
if (null !== $byUser) {
$this->byUserId = $byUser->getId();
}
}
public function getByUserId(): ?int
{
return $this->byUserId;
}
public function getCalendarUserId(): ?int
{
return $this->calendarUserId;
}
public function getRemoteAttributes(): array
{
return $this->remoteAttributes;
}
public function getRemoteId(): string
{
return $this->remoteId;
}
/**
* @return int|null
*/
public function getAssociatedCalendarRangeId(): ?int
{
return $this->associatedCalendarRangeId;
}
}