$value) { if (!property_exists($this, $key)) { throw new \InvalidArgumentException('Unknown option: ' . $key); } $this->$key = $value; } } /** * The xmlSerialize metod is called during xml writing. * * Use the $writer argument to write its own xml serialization. * * An important note: do _not_ create a parent element. Any element * implementing XmlSerializble should only ever write what's considered * its 'inner xml'. * * The parent of the current element is responsible for writing a * containing element. * * This allows serializers to be re-used for different element names. * * If you are opening new elements, you must also close them again. * * @param Writer $writer * @return void */ function xmlSerialize(Writer $writer) { $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-notification'); } /** * This method serializes the entire notification, as it is used in the * response body. * * @param Writer $writer * @return void */ function xmlSerializeFull(Writer $writer) { $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; $this->dtStamp->setTimezone(new \DateTimezone('GMT')); $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); $writer->startElement($cs . 'invite-notification'); $writer->writeElement($cs . 'uid', $this->id); $writer->writeElement('{DAV:}href', $this->href); switch ($this->type) { case SharingPlugin::STATUS_ACCEPTED : $writer->writeElement($cs . 'invite-accepted'); break; case SharingPlugin::STATUS_DECLINED : $writer->writeElement($cs . 'invite-declined'); break; case SharingPlugin::STATUS_DELETED : $writer->writeElement($cs . 'invite-deleted'); break; case SharingPlugin::STATUS_NORESPONSE : $writer->writeElement($cs . 'invite-noresponse'); break; } $writer->writeElement($cs . 'hosturl', [ '{DAV:}href' => $writer->contextUri . $this->hostUrl ]); if ($this->summary) { $writer->writeElement($cs . 'summary', $this->summary); } $writer->startElement($cs . 'access'); if ($this->readOnly) { $writer->writeElement($cs . 'read'); } else { $writer->writeElement($cs . 'read-write'); } $writer->endElement(); // access $writer->startElement($cs . 'organizer'); // If the organizer contains a 'mailto:' part, it means it should be // treated as absolute. if (strtolower(substr($this->organizer, 0, 7)) === 'mailto:') { $writer->writeElement('{DAV:}href', $this->organizer); } else { $writer->writeElement('{DAV:}href', $writer->contextUri . $this->organizer); } if ($this->commonName) { $writer->writeElement($cs . 'common-name', $this->commonName); } if ($this->firstName) { $writer->writeElement($cs . 'first-name', $this->firstName); } if ($this->lastName) { $writer->writeElement($cs . 'last-name', $this->lastName); } $writer->endElement(); // organizer if ($this->commonName) { $writer->writeElement($cs . 'organizer-cn', $this->commonName); } if ($this->firstName) { $writer->writeElement($cs . 'organizer-first', $this->firstName); } if ($this->lastName) { $writer->writeElement($cs . 'organizer-last', $this->lastName); } if ($this->supportedComponents) { $writer->writeElement('{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set', $this->supportedComponents); } $writer->endElement(); // invite-notification } /** * Returns a unique id for this notification * * This is just the base url. This should generally be some kind of unique * id. * * @return string */ function getId() { return $this->id; } /** * Returns the ETag for this notification. * * The ETag must be surrounded by literal double-quotes. * * @return string */ function getETag() { return $this->etag; } }