Scalr\Model\AbstractEntity::getIterator PHP Méthode

getIterator() public méthode

See also: IteratorAggregate::getIterator()
public getIterator ( ) : Scalr\Model\EntityPropertiesIterator
Résultat Scalr\Model\EntityPropertiesIterator Gets EntityPropertiesIterator
    public function getIterator()
    {
        if (!$this->iterator) {
            $class = get_class($this);
            if (!isset(self::$cache[$class]['iterator'])) {
                self::$cache[$class]['iterator'] = new EntityPropertiesIterator($this);
                $this->iterator = self::$cache[$class]['iterator'];
            } else {
                $this->iterator = clone self::$cache[$class]['iterator'];
                $this->iterator->setEntity($this);
            }
        }
        return $this->iterator;
    }

Usage Example

Exemple #1
0
 /**
  * Constructor
  *
  * @param   AbstractEntity $entity The target
  * @param   string         $field  The field name
  */
 public function __construct(AbstractEntity $entity, $field)
 {
     $this->entity = $entity;
     if (!$entity instanceof AbstractEntity) {
         throw new \InvalidArgumentException("The first argument should be instance of the AbstractEntity class.");
     }
     $this->field = $this->entity->getIterator()->getField($field);
     if (!$this->field) {
         throw new ModelException(sprintf("Invalid field %s for entity %s", $field, get_class($this->entity)));
     }
 }
All Usage Examples Of Scalr\Model\AbstractEntity::getIterator