mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
wip: continue sync to remote
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Messenger\Handler;
|
||||
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarMessage;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface;
|
||||
@@ -62,12 +63,17 @@ class CalendarToRemoteHandler implements MessageHandlerInterface
|
||||
if (null !== $calendarMessage->getPreviousCalendarRangeId()) {
|
||||
$previousCalendarRange = $this->calendarRangeRepository
|
||||
->find($calendarMessage->getPreviousCalendarRangeId());
|
||||
} else {
|
||||
$previousCalendarRange = null;
|
||||
}
|
||||
|
||||
if (null !== $calendarMessage->getPreviousMainUserId()) {
|
||||
$previousMainUser = $this->userRepository
|
||||
->find($calendarMessage->getPreviousMainUserId());
|
||||
} else {
|
||||
$previousMainUser = null;
|
||||
}
|
||||
|
||||
$newInvites = array_filter(
|
||||
array_map(
|
||||
function ($id) { return $this->inviteRepository->find($id); },
|
||||
@@ -79,13 +85,22 @@ class CalendarToRemoteHandler implements MessageHandlerInterface
|
||||
$this->calendarConnector->syncCalendar(
|
||||
$calendar,
|
||||
$calendarMessage->getAction(),
|
||||
$previousCalendarRange ?? null,
|
||||
$previousMainUser ?? null,
|
||||
$previousCalendarRange,
|
||||
$previousMainUser,
|
||||
$calendarMessage->getOldInvites(),
|
||||
$newInvites
|
||||
);
|
||||
|
||||
$calendar->preventEnqueueChanges = true;
|
||||
|
||||
if ($calendar->hasCalendarRange()) {
|
||||
$calendar->getCalendarRange()->preventEnqueueChanges = true;
|
||||
}
|
||||
|
||||
if ($previousCalendarRange instanceof CalendarRange) {
|
||||
$previousCalendarRange->preventEnqueueChanges = true;
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user