Exemple #1
0
 /**
  * Register an event
  * @param \ical\Event $event
  * @return void
  */
 protected static function registerEvent(\ical\Event $event)
 {
     if (!self::eventExists($event->uid)) {
         self::$events[$event->uid] = $event;
     } else {
         self::$events[$event->uid] = $event->merge(self::$events[$event->uid]);
     }
 }
Exemple #2
0
 /**
  * Parses row values from a chunk
  * @param ical\parser\Chunk $chunk
  * @return void
  * @throws UnexpectedValueException
  */
 public function parseProperties(\ical\parser\Chunk $chunk)
 {
     if ($chunk->type !== \ical\parser\Chunk::TYPE_CALENDAR) {
         throw new \UnexpectedValueException("Invalid chunk type:" . $chunk->type . ", expected:" . \ical\parser\Chunk::TYPE_CALENDAR);
     }
     foreach ($chunk->getLines() as $line) {
         switch ($line->name) {
             case 'VERSION':
                 $this->version = $line->value;
                 break;
             case 'PRODID':
                 $this->prodid = $line->value;
                 break;
             case 'CALSCALE':
                 $this->calscale = $line->value;
                 break;
             case 'METHOD':
                 $this->method = $line->value;
                 break;
             case 'X-WR-TIMEZONE':
                 \ical\Event::setDefaultTimezone(new \DateTimeZone($line->value));
                 break;
             default:
                 if ('X-' === substr($line->name, 0, 2)) {
                     $this->extended[$line->name] = $line->value;
                 }
                 break;
         }
     }
 }
Exemple #3
0
 protected function processChunks($chunks)
 {
     $calendar = new \ical\Calendar();
     // Find the CALENDAR chunk
     foreach ($chunks as $chunk) {
         if (\ical\parser\Chunk::TYPE_CALENDAR === $chunk->type) {
             $calendar = \ical\Calendar::createFromChunk($chunk);
             break;
         }
     }
     foreach ($chunks as $chunk) {
         switch ($chunk->type) {
             case \ical\parser\Chunk::TYPE_TIMEZONE:
                 break;
             case \ical\parser\Chunk::TYPE_TZ_DST:
                 break;
             case \ical\parser\Chunk::TYPE_TZ_STD:
                 break;
             case \ical\parser\Chunk::TYPE_EVENT:
                 $event = \ical\Event::createFromChunk($chunk);
                 $calendar->addEvent($event);
                 break;
         }
     }
     return $calendar;
 }