Sabre\VObject\ITip\Broker::processMessageRequest PHP Method

processMessageRequest() protected method

This is message from an organizer, and is either a new event invite, or an update to an existing one.
protected processMessageRequest ( Sabre\VObject\ITip\Message $itipMessage, Sabre\VObject\Component\VCalendar $existingObject = null ) : Sabre\VObject\Component\VCalendar | null
$itipMessage Sabre\VObject\ITip\Message
$existingObject Sabre\VObject\Component\VCalendar
return Sabre\VObject\Component\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;
    }