Exemplo n.º 1
0
 /**
  * Processes incoming REQUEST messages.
  *
  * This is message from an organizer, and is either a new event
  * invite, or an update to an existing one.
  *
  *
  * @param Message $itipMessage
  * @param VCalendar $existingObject
  * @return VCalendar|null
  */
 protected function processMessageRequest(Message $itipMessage, VCalendar $existingObject = null)
 {
     if (!$existingObject) {
         // This is a new invite, and we're just going to copy over
         // all the components from the invite.
         $existingObject = new VCalendar();
         foreach ($itipMessage->message->getComponents() as $component) {
             $existingObject->add(clone $component);
         }
     } else {
         // We need to update an existing object with all the new
         // information. We can just remove all existing components
         // and create new ones.
         foreach ($existingObject->getComponents() as $component) {
             $existingObject->remove($component);
         }
         foreach ($itipMessage->message->getComponents() as $component) {
             $existingObject->add(clone $component);
         }
     }
     return $existingObject;
 }
Exemplo n.º 2
0
 function testGetComponents()
 {
     $comp = new VCalendar();
     $comp->add($comp->createProperty('FOO', 'BAR'));
     $comp->add($comp->createComponent('VTODO'));
     $r = $comp->getComponents();
     $this->assertInternalType('array', $r);
     $this->assertEquals(1, count($r));
     $this->assertEquals('VTODO', $r[0]->name);
 }