mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
recreate calendar range when an event is deleted
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user