/**
  * Modify the given times via the configuration
  *
  * @param array         $times
  * @param Configuration $configuration
  *
  * @return void
  */
 public function handleConfiguration(array &$times, Configuration $configuration)
 {
     $url = $configuration->getExternalIcsUrl();
     if (!GeneralUtility::isValidUrl($url)) {
         HelperUtility::createFlashMessage('Configuration with invalid ICS URL: ' . $url, 'Index ICS URL', FlashMessage::ERROR);
         return;
     }
     $events = $this->icsReaderService->toArray($url);
     foreach ($events as $event) {
         /** @var $event ICalEvent */
         $startTime = DateTimeUtility::getDaySecondsOfDateTime($event->getStart());
         $endTime = DateTimeUtility::getDaySecondsOfDateTime($event->getEnd());
         if ($endTime === self::DAY_END) {
             $endTime = 0;
         }
         $entry = ['pid' => 0, 'start_date' => $event->getStart(), 'end_date' => $event->getEnd() ?: $event->getStart(), 'start_time' => $startTime, 'end_time' => $endTime, 'all_day' => $endTime === 0];
         $times[] = $entry;
     }
 }
Example #2
0
 /**
  * Get the configuration
  *
  * @param int       $pid
  * @param \DateTime $startDate
  * @param \DateTime $endDate
  *
  * @return Configuration
  */
 protected function getConfiguration($pid, \DateTime $startDate, \DateTime $endDate)
 {
     $configuration = new Configuration();
     $configuration->setPid($pid);
     $configuration->setType(Configuration::TYPE_TIME);
     $configuration->setFrequency(Configuration::FREQUENCY_NONE);
     $configuration->setAllDay(true);
     $startTime = clone $startDate;
     $configuration->setStartDate(DateTimeUtility::resetTime($startDate));
     $endTime = $endDate;
     $configuration->setEndDate(DateTimeUtility::resetTime($endDate));
     $startTime = DateTimeUtility::getDaySecondsOfDateTime($startTime);
     if ($startTime > 0) {
         $configuration->setStartTime($startTime);
         $configuration->setEndTime(DateTimeUtility::getDaySecondsOfDateTime($endTime));
         $configuration->setAllDay(false);
     }
     return $configuration;
 }