/** * Convert google object to model * * @param \Google_Service_Calendar_EventCreator $creatorItem * @param \KevinDitscheid\KdCalendar\Domain\Model\Creator $creator * * @return \KevinDitscheid\KdCalendar\Domain\Model\Creator */ public static function convert($creatorItem, $creator = NULL) { $feUserRepository = self::getFrontendUserRepositoryInstance(); $feUser = $feUserRepository->findByEmail($creatorItem->getEmail())->getFirst(); if ($feUser === NULL) { $feUser = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUser(); $feUser->setUsername($creatorItem->getEmail()); $feUser->setName($creatorItem->getDisplayName()); $feUser->setEmail($creatorItem->getEmail()); $feUserRepository->add($feUser); self::persist(); } if ($creator === NULL) { $creator = new \KevinDitscheid\KdCalendar\Domain\Model\Creator(); } $creator->setFeUser($feUser); $creator->setId($creatorItem->getId()); $creator->setSelf($creatorItem->getSelf()); return $creator; }
/** * Fill data from google object into model * * @param \Google_Service_Calendar_EventAttendee $attendeeItem * @param \KevinDitscheid\KdCalendar\Domain\Model\Attendees $attendee * * @return \KevinDitscheid\KdCalendar\Domain\Model\Attendees */ public static function convert($attendeeItem, $attendee = NULL) { $feUserRepository = self::getFrontendUserRepositoryInstance(); $feUser = $feUserRepository->findByEmail($attendeeItem->getEmail())->getFirst(); if ($feUser === NULL) { $feUser = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUser(); $feUser->setUsername($attendeeItem->getEmail()); $feUser->setName($attendeeItem->getDisplayName()); $feUser->setEmail($attendeeItem->getEmail()); $feUserRepository->add($feUser); self::persist(); } if ($attendee === NULL) { $attendee = new \KevinDitscheid\KdCalendar\Domain\Model\Attendees(); } $attendee->setAdditionalGuests($attendeeItem->getAdditionalGuests()); $attendee->setComment($attendeeItem->getComment()); $attendee->setId($attendeeItem->getId()); $attendee->setOptional($attendeeItem->getOptional()); $attendee->setOrganizer($attendeeItem->getOrganizer()); $attendee->setResource($attendeeItem->getResource()); $attendee->setResponseStatus($attendeeItem->getResponseStatus()); $attendee->setSelf($attendeeItem->getSelf()); return $attendee; }