class RecursiveDOMIterator in Translation Management Tool 8
Class used to iterate through DOMDocument.
Hierarchy
- class \Drupal\tmgmt_file\RecursiveDOMIterator implements \Drupal\tmgmt_file\RecursiveIterator
Expanded class hierarchy of RecursiveDOMIterator
1 file declares its use of RecursiveDOMIterator
File
- translators/
tmgmt_file/ src/ RecursiveDOMIterator.php, line 8
Namespace
Drupal\tmgmt_fileView source
class RecursiveDOMIterator implements \RecursiveIterator {
/**
* Current position in DOMNodeList.
*
* @var int
*/
protected $position;
/**
* The DOMNodeList with all children to iterate over.
*
* @var \DOMNodeList
*/
protected $nodeList;
/**
* Constructor.
*
* @param DOMNode $domNode
* DOMNode to iterate over.
*/
public function __construct(\DOMNode $domNode) {
$this->position = 0;
$this->nodeList = $domNode->childNodes;
}
/**
* Returns the current DOMNode.
*
* @return DOMNode
* Current DOMNode object.
*/
public function current() {
return $this->nodeList
->item($this->position);
}
/**
* Returns an iterator for the current iterator entry.
*
* @return RecursiveDOMIterator
* Iterator with children elements.
*/
public function getChildren() {
return new self($this
->current());
}
/**
* Checks if current element has children.
*
* @return bool
* Has children.
*/
public function hasChildren() {
return $this
->current()
->hasChildNodes();
}
/**
* Returns the current position.
*
* @return int
* Current position
*/
public function key() {
return $this->position;
}
/**
* Moves the current position to the next element.
*/
public function next() {
$this->position++;
}
/**
* Rewind the Iterator to the first element.
*/
public function rewind() {
$this->position = 0;
}
/**
* Checks if current position is valid.
*
* @return bool
* Is valid.
*/
public function valid() {
return $this->position < $this->nodeList->length;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RecursiveDOMIterator:: |
protected | property | The DOMNodeList with all children to iterate over. | |
RecursiveDOMIterator:: |
protected | property | Current position in DOMNodeList. | |
RecursiveDOMIterator:: |
public | function | Returns the current DOMNode. | |
RecursiveDOMIterator:: |
public | function | Returns an iterator for the current iterator entry. | |
RecursiveDOMIterator:: |
public | function | Checks if current element has children. | |
RecursiveDOMIterator:: |
public | function | Returns the current position. | |
RecursiveDOMIterator:: |
public | function | Moves the current position to the next element. | |
RecursiveDOMIterator:: |
public | function | Rewind the Iterator to the first element. | |
RecursiveDOMIterator:: |
public | function | Checks if current position is valid. | |
RecursiveDOMIterator:: |
public | function | Constructor. |