Prado\Collections\TPagedList::getIterator PHP Method

getIterator() public method

public getIterator ( ) : Iterator
return Iterator iterator
    public function getIterator()
    {
        if ($this->_customPaging) {
            return parent::getIterator();
        } else {
            $data = $this->toArray();
            return new \ArrayIterator($data);
        }
    }

Usage Example

コード例 #1
0
ファイル: TPagedListTest.php プロジェクト: pradosoft/prado
 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);
 }