public function testIteratorAggregateCollection() { $array = $this->getArrayData(); $iterator = new \ArrayIterator($array); $data = new DelegatingIterator($iterator); $collection = new Collection($data); $this->assertSame($iterator, $collection->getRaw()); $this->assertEquals($array[0], $collection->getPeek()->getRaw()); $this->assertEquals($array[0], $collection->next()->getRaw()); $this->assertEquals($array[1], $collection->next()->getRaw()); $this->assertEquals($array[2], $collection->getPeek()->getRaw()); $collection->rewind(); $this->assertEquals($array[0], $collection->next()->getRaw()); }
/** * {@inheritdoc} */ public function buildGrid(Grid $grid, Schema $schema, Collection $collection, array $options = array()) { $index = 0; while ($entity = $collection->next()) { $schema->build($row = new Row(self::NAME), $entity, $options); $grid->getBody()->add($entity->getId() ?: $index++, $row); } }