Skip to content

Commit

Permalink
Fixed integration with Google Calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
inshop committed Aug 22, 2019
1 parent 489544b commit 083b091
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/EventListener/TaskListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ public function postUpdate(LifecycleEventArgs $eventArgs): void
$changes = $unitOfWork->getEntityChangeSet($entity);

if (array_key_exists('assignee', $changes)) {
$this->googleClient->deleteEvent($entity, $changes['assignee'][0]);
$this->googleClient->insertEvent($entity, $changes['assignee'][1]);
if ($changes['assignee'][0]) {
$this->googleClient->deleteEvent($entity, $changes['assignee'][0]);
}

if ($changes['assignee'][1]) {
$this->googleClient->insertEvent($entity, $changes['assignee'][1]);
}
} else {
$this->googleClient->updateEvent($entity, $entity->getAssignee());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Service/GoogleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ public function getCalendars(): \Google_Service_Calendar_CalendarList
/**
* @param Task $task
* @param User $user
* @return \Google_Service_Calendar_Event
* @return \Google_Service_Calendar_Event|null
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
public function insertEvent(Task $task, User $user): \Google_Service_Calendar_Event
public function insertEvent(Task $task, User $user): ?\Google_Service_Calendar_Event
{
if (!$user->getIsGoogleSyncEnabled() || !$user->getGoogleCalendarId()) {
return null;
Expand Down

0 comments on commit 083b091

Please sign in to comment.