Prado\Collections\TPagedList::getIterator PHP Метод

getIterator() публичный Метод

public getIterator ( ) : Iterator
Результат Iterator iterator
    public function getIterator()
    {
        if ($this->_customPaging) {
            return parent::getIterator();
        } else {
            $data = $this->toArray();
            return new \ArrayIterator($data);
        }
    }

Usage Example

Пример #1
0
 public function testGetIterator()
 {
     $list = new TPagedList(array(1, 2));
     $list->CustomPaging = true;
     self::assertInstanceOf('ArrayIterator', $list->getIterator());
     $n = 0;
     $found = 0;
     foreach ($list as $index => $item) {
         foreach ($list as $a => $b) {
         }
         // test of iterator
         $n++;
         if ($index === 0 && $item === 1) {
             $found++;
         }
         if ($index === 1 && $item === 2) {
             $found++;
         }
     }
     self::assertTrue($n == 2 && $found == 2);
 }