/** * TODO * * @param string $id The identifier used to be able to retrieve data to be written afterwards. * @param IMetaData The metadata to be written. * @param array $params Additional params implementation-dependant. */ public function storeMeta($id, IMetaData $metaData, $params = null) { $xml = new SimpleXMLElement('<meta/>'); $metaDatas = $metaData->getAll(); foreach ($metaDatas as $key => $value) { if (is_array($value)) { $node = $xml->addChild('entry'); $node->addAttribute('key', $key); $node->addAttribute('type', 'array'); $this->writeArray($node, $value); } else { if (is_bool($value)) { $node = $xml->addChild('entry', $value ? 'true' : 'false'); $node->addAttribute('key', $key); } else { $node = $xml->addChild('entry', $value); $node->addAttribute('key', $key); } } } try { $xmlWriter = new XmlStreamWriter(new FileOutputStream($this->filePath), array(XmlStreamWriter::PARAM_FORMATOUTPUT => $this->formatOutput)); $xmlWriter->write($xml); } catch (Exception $e) { //close stream try { if (is_object($xmlWriter)) { $xmlWriter->close(); } } catch (Exception $e) { } throw new EyeIOException('Unable to write meta file at ' . $this->filePath . '.', 0, $e); } //close stream try { if (is_object($xmlWriter)) { $xmlWriter->close(); } } catch (Exception $e) { } //Update cache self::$Cache[$this->filePath] = $metaData->getAll(); }
/** * * @param SimpleXmlElement $xml */ protected function saveMountpointsFile(SimpleXmlElement $xml) { try { if (!is_file($this->filePath)) { throw new EyeFileNotFoundException($this->filePath); } $xmlWriter = new XmlStreamWriter(new FileOutputStream($this->filePath), array(XmlStreamWriter::PARAM_FORMATOUTPUT => true)); $xmlWriter->write($xml); $xmlWriter->close(); } catch (Exception $e) { throw new EyeIOException('Unable to save mountpoints configuration at ' . $this->filePath . '.', 0, $e); } }