Skip to content

Commit

Permalink
Merge pull request #10 from krichprollsch/attendee-without-status
Browse files Browse the repository at this point in the history
Attendee could have no status from Api payload
  • Loading branch information
Taluu committed Nov 12, 2015
2 parents 73ce40e + a0c567d commit 8a7b878
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,14 @@ public static function hydrate(array $data, Calendar $calendar = null)
}

$participation = new EventParticipation($event, $user, $role, EventParticipation::STATUS_NONE);
$participation->setStatus(EventParticipation::translateStatus($attendee['Status']['Response']));
$participation->setType(EventParticipation::translateType($attendee['Type']));
if (isset($attendee['Status'])) {
$participation->setStatus(EventParticipation::translateStatus($attendee['Status']['Response']));

if (EventParticipation::STATUS_NONE !== $participation->getStatus()) {
$participation->setAnsweredAt(new Datetime($attendee['Status']['Time']));
if (EventParticipation::STATUS_NONE !== $participation->getStatus()) {
$participation->setAnsweredAt(new Datetime($attendee['Status']['Time']));
}
}
$participation->setType(EventParticipation::translateType($attendee['Type']));

$user->addEvent($event);
$event->participations->add($participation);
Expand Down

0 comments on commit 8a7b878

Please sign in to comment.