本文整理汇总了PHP中XMLWriter::getDepth方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::getDepth方法的具体用法?PHP XMLWriter::getDepth怎么用?PHP XMLWriter::getDepth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::getDepth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _serialize
/**
* Utilize custom serialization for XMLWriter object, to convert object
* to SQL.
*
* @return string
*/
private function _serialize()
{
$this->setIndent(true);
$this->setIndentString(' ');
$this->startDocument('1.0', 'UTF-8');
$this->_namespaces = array();
$this->_tagStack = array();
$this->_state = array();
$this->_type = 'Tag';
$this->_expectedDepth = 0;
$this->_lastkey = array();
$lastdepth = 0;
foreach ($this->_iter = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->_array), \RecursiveIteratorIterator::SELF_FIRST) as $key => $values) {
$depth = $this->_iter->getDepth();
while ($depth < $this->_expectedDepth) {
// finished with this tag
$this->_finish($key, $values);
$lastdepth--;
}
if (isset($this->_lastkey[$depth]) && $key != $this->_lastkey[$depth]) {
while ($lastdepth > $depth) {
$this->_finish($key, $values);
$lastdepth--;
}
}
$this->_lastkey[$depth] = $key;
foreach ($this->_lastkey as $d => &$k) {
if ($d > $depth) {
$k = false;
}
}
$this->_lastkey = array_filter($this->_lastkey, array('Pyrus\\XMLWriter', '_filter'));
$lastdepth = $depth;
if ($this->_type !== 'Attribs') {
if ($key === '_content') {
$this->text($values);
continue;
}
if ($key === 'attribs') {
// attributes are 1 depth higher
$this->_pushState();
$this->_expectedDepth = $this->_iter->getDepth() + 1;
$this->_type = 'Attribs';
// cycle to first attribute
continue;
}
}
$next = '_handle' . $this->_type;
while ($next = $this->{$next}($key, $values)) {
}
}
while ($lastdepth) {
$this->_finish($key, $values);
$lastdepth--;
}
$this->endDocument();
return $this->flush();
}