You are here

class EntityMetadataWrapperIterator in Entity API 7

Allows to easily iterate over existing child wrappers.

Hierarchy

Expanded class hierarchy of EntityMetadataWrapperIterator

File

includes/entity.wrapper.inc, line 1201
Provides wrappers allowing easy usage of the entity metadata.

View source
class EntityMetadataWrapperIterator implements RecursiveIterator {
  protected $position = 0;
  protected $wrapper, $keys;
  public function __construct(EntityMetadataWrapper $wrapper, array $keys) {
    $this->wrapper = $wrapper;
    $this->keys = $keys;
  }
  public function rewind() {
    $this->position = 0;
  }
  public function current() {
    return $this->wrapper
      ->get($this->keys[$this->position]);
  }
  public function key() {
    return $this->keys[$this->position];
  }
  public function next() {
    $this->position++;
  }
  public function valid() {
    return isset($this->keys[$this->position]);
  }
  public function hasChildren() {
    return $this
      ->current() instanceof IteratorAggregate;
  }
  public function getChildren() {
    return $this
      ->current()
      ->getIterator();
  }

}

Members