protected function getSerializedOptions(QueryOptions $options)
 {
     $expressionSerializer = $this->componentSerializer;
     return array('objectType' => 'queryOptions', 'limit' => $options->getLimit(), 'offset' => $options->getOffset(), 'sort' => array('expressions' => array_map(function (SortExpression $expression) use($expressionSerializer) {
         return $expressionSerializer->serialize($expression);
     }, $options->getSort()->getExpressions())));
 }
Пример #2
0
 /**
  * @dataProvider constructorArgumentProvider
  */
 public function testConstructSetsFields($limit, $offset, SortOptions $sort)
 {
     $queryOptions = new QueryOptions($limit, $offset, $sort);
     $this->assertEquals($limit, $queryOptions->getLimit());
     $this->assertEquals($offset, $queryOptions->getOffset());
     $this->assertEquals($sort, $queryOptions->getSort());
 }
Пример #3
0
 private function getCacheId(Description $description, QueryOptions $queryOptions = null, $entityType)
 {
     $key = self::CACHE_ID_PREFIX . WIKIBASE_DATAMODEL_VERSION . '-' . $entityType . '-' . $description->getHash();
     if ($queryOptions !== null) {
         $key .= '-' . $queryOptions->getOffset() . '-' . $queryOptions->getLimit();
     }
     return $key;
 }
 private function applyOptionsToCursor(Cursor $cursor, QueryOptions $options)
 {
     if ($this->timeLimit !== null) {
         $cursor->timeout($this->timeLimit);
     }
     return $cursor->skip($options->getOffset())->limit($options->getLimit());
 }