save() public method

Convert the data to a XML stream. Strings contained in the data array may only be provided as UTF-8 data.
public save ( array $object, array $options = [] ) : string
$object array The data array representing the object.
$options array Additional options when writing the XML.
- previous: The previous XML text (default: empty string)
- relaxed: Relaxed error checking (default: false)
return string The data as an XML string.
Example #1
0
 public function testRoundtripWithPreviousOnApiV1()
 {
     $xml = new Horde_Kolab_Format_Xml(new Horde_Kolab_Format_Xml_Parser(new DOMDocument('1.0', 'UTF-8')), new Horde_Kolab_Format_Factory(), array('version' => 1));
     $first = $xml->save(array('uid' => 1));
     $second = $xml->save($xml->load($first));
     $this->assertEquals($this->removeLastModification($first), $this->removeLastModification($second));
 }
Example #2
0
 /**
  * Convert the data to a XML stream. Strings contained in the data array may
  * only be provided as UTF-8 data.
  *
  * @param array $object  The data array representing the object.
  * @param array $options Additional options when parsing the XML.
  * <pre>
  * - previous: The previous XML text (default: empty string)
  * - relaxed: Relaxed error checking (default: false)
  * </pre>
  *
  * @return resource The data as XML stream.
  *
  * @throws Horde_Kolab_Format_Exception If converting the data to XML failed.
  */
 public function save($object, $options = array())
 {
     if (!isset($object['type'])) {
         throw new Horde_Kolab_Format_Exception('The "type" value is missing!');
     }
     $this->_root_name = $object['type'];
     return parent::save($object, $options);
 }
Example #3
0
 /**
  * Convert the data to a XML stream. Strings contained in the data array may
  * only be provided as UTF-8 data.
  *
  * @param array $object  The data array representing the object.
  * @param array $options Additional options when writing the XML.
  * <pre>
  * - previous: The previous XML text (default: empty string)
  * - relaxed: Relaxed error checking (default: false)
  * </pre>
  *
  * @return resource The data as XML stream.
  *
  * @throws Horde_Kolab_Format_Exception If converting the data to XML failed.
  */
 public function save($object, $options = array())
 {
     if (!empty($object['_is_all_day'])) {
         $this->_fields_specific['start-date'] = 'Horde_Kolab_Format_Xml_Type_EventDate';
         $this->_fields_specific['end-date'] = 'Horde_Kolab_Format_Xml_Type_EventDate';
         $end_date = clone $object['end-date'];
         if ($end_date->hour == 0 && $end_date->min == 0 && $end_date->sec == 0) {
             // move date to previous day 23:59:59. We cut off the time anyway.
             $end_date->sub(new DateInterval('PT1S'));
             $object['end-date'] = $end_date;
         }
     }
     return parent::save($object, $options);
 }