You are here

class CerEndPointIterator in Corresponding Entity References 7.3

@class The purpose of this iterator is to wrap around all the "endpoints" in a field chain. An endpoint is a CerFieldHandler for a field that hasn't got a child. This is necessary in order to support infinite levels of embedded entities (read: field collections). This class is only instantiated by CerFieldChainHandler if its initial field handler has a child (

Hierarchy

Expanded class hierarchy of CerEndPointIterator

See also

CerFieldHandler::__construct()).

File

includes/CerEndPointIterator.inc, line 16
Contains CerEndPointIterator.

View source
class CerEndPointIterator implements RecursiveIterator {

  /**
   * @var CerField
   */
  protected $field;

  /**
   * @var CerFieldHandler
   */
  protected $handler;
  public function __construct(CerField $field, EntityDrupalWrapper $entity) {
    $this->field = $field;
    $this->handler = $field
      ->getHandler($entity);
  }

  /**
   * Implements Iterator::current().
   */
  public function current() {
    return $this->field
      ->child()
      ->getHandler($this->handler
      ->current());
  }

  /**
   * Implements Iterator::key().
   */
  public function key() {
    return $this->handler
      ->key();
  }

  /**
   * Implements Iterator::next().
   */
  public function next() {
    $this->handler
      ->next();
  }

  /**
   * Implements Iterator::rewind().
   */
  public function rewind() {
    $this->handler
      ->rewind();
  }

  /**
   * Implements Iterator::handler().
   */
  public function valid() {
    return $this->handler
      ->valid();
  }

  /**
   * Implements RecursiveIterator::hasChildren().
   */
  public function hasChildren() {
    return $this->field
      ->child() instanceof CerEntityContainerInterface;
  }

  /**
   * Implements RecursiveIterator::getChildren().
   */
  public function getChildren() {
    return new CerEndPointIterator($this->field
      ->child(), $this->handler
      ->current());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CerEndPointIterator::$field protected property
CerEndPointIterator::$handler protected property
CerEndPointIterator::current public function Implements Iterator::current().
CerEndPointIterator::getChildren public function Implements RecursiveIterator::getChildren().
CerEndPointIterator::hasChildren public function Implements RecursiveIterator::hasChildren().
CerEndPointIterator::key public function Implements Iterator::key().
CerEndPointIterator::next public function Implements Iterator::next().
CerEndPointIterator::rewind public function Implements Iterator::rewind().
CerEndPointIterator::valid public function Implements Iterator::handler().
CerEndPointIterator::__construct public function