ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Writer.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\VObject;
4 
5 use Sabre\Xml;
6 
17 class Writer {
18 
26  static function write(Component $component) {
27 
28  return $component->serialize();
29 
30  }
31 
40  static function writeJson(Component $component, $options = 0) {
41 
42  return json_encode($component, $options);
43 
44  }
45 
53  static function writeXml(Component $component) {
54 
55  $writer = new Xml\Writer();
56  $writer->openMemory();
57  $writer->setIndent(true);
58 
59  $writer->startDocument('1.0', 'utf-8');
60 
61  if ($component instanceof Component\VCalendar) {
62 
63  $writer->startElement('icalendar');
64  $writer->writeAttribute('xmlns', Parser\Xml::XCAL_NAMESPACE);
65 
66  } else {
67 
68  $writer->startElement('vcards');
69  $writer->writeAttribute('xmlns', Parser\Xml::XCARD_NAMESPACE);
70 
71  }
72 
73  $component->xmlSerialize($writer);
74 
75  $writer->endElement();
76 
77  return $writer->outputMemory();
78 
79  }
80 
81 }
iCalendar/vCard/jCal/jCard/xCal/xCard writer object.
Definition: Writer.php:17
The VCalendar component.
Definition: VCalendar.php:23
static write(Component $component)
Serializes a vCard or iCalendar object.
Definition: Writer.php:26
serialize()
Turns the object back into a serialized blob.
Definition: Component.php:284
static writeJson(Component $component, $options=0)
Serializes a jCal or jCard object.
Definition: Writer.php:40
static writeXml(Component $component)
Serializes a xCal or xCard object.
Definition: Writer.php:53
xmlSerialize(Xml\Writer $writer)
This method serializes the data into XML.
Definition: Component.php:391
The XML Writer class.
Definition: Writer.php:31