Neos\Flow\Persistence\Doctrine\Query::setOffset PHP Method

setOffset() public method

Sets the start offset of the result set to offset. Returns $this to allow for chaining (fluid interface)
public setOffset ( integer $offset ) : Neos\Flow\Persistence\QueryInterface
$offset integer
return Neos\Flow\Persistence\QueryInterface
    public function setOffset($offset)
    {
        $this->offset = $offset;
        $this->queryBuilder->setFirstResult($offset);
        return $this;
    }

Usage Example

 /**
  * @test
  */
 public function countRespectsOffsetConstraint()
 {
     $testEntityRepository = new Fixtures\TestEntityRepository();
     $testEntityRepository->removeAll();
     $testEntity1 = new Fixtures\TestEntity();
     $testEntity1->setName('Flow');
     $testEntityRepository->add($testEntity1);
     $testEntity2 = new Fixtures\TestEntity();
     $testEntity2->setName('some');
     $testEntityRepository->add($testEntity2);
     $testEntity3 = new Fixtures\TestEntity();
     $testEntity3->setName('more');
     $testEntityRepository->add($testEntity3);
     $this->persistenceManager->persistAll();
     $query = new Query(Fixtures\TestEntity::class);
     $this->assertEquals(1, $query->setOffset(2)->execute()->count());
 }