Process pagination

@param array    $pagination
@param Criteria $criteria
10334
protected function processPagination(array $pagination, Criteria $criteria): void
    {
        if (isset($pagination['offset'])) {
            $criteria->setFirstResult((int) $pagination['offset']);
        }

        if (isset($pagination['limit'])) {
            $criteria->setMaxResults((int) $pagination['limit']);
        }
    }
53707
public function getPaginator($criteria = [], array $fields = []) {
		$criteriaNormalized = $this->normalizeCriteria($criteria);
		
		$mongoCursor = $this->getAdapter()->find(
			$this->getTableName(),
			$criteriaNormalized,
			$fields
		);
		
		if ($criteria instanceof Criteria) {
			$this->applyCriteriaToCursor($criteria, $mongoCursor);
		}
		
		return new Paginator(new PaginatorAdapter($mongoCursor, $this));
	}
823275
public static function queryCount( ezpContentCriteria $criteria )
    {
        $fetchParams = self::translateFetchParams( $criteria );
        $count = eZContentObjectTreeNode::subTreeCountByNodeID( $fetchParams->params, $fetchParams->rootNodeId );
        return $count;
    }
1182502
protected function processFilter(string $name, array $values, Criteria $criteria, Context $context): void
    {
        foreach ($values as $operator => $value)
        {
            if (is_integer($operator)) {
                throw new InvalidQueryException('Operator must be defined by a string.');
            }

            $value = is_array($value) ? array_map('trim', $value) : trim($value);

            $expression = $this->createExpression($name, trim($operator), $value, $context);
            $criteria->andWhere($expression);
        }
    }
398938
public function process($query, $format = null, $timeout = 6000, $pagination = true)
    {
        $this->timeout = $timeout;
        $factory = new RequestProcessorFactory();
        $processor = $factory->create(gettype($query));
        $request = $processor->convertToObjectRequest($query);
        $validation = $this->validate($request);
        if ($validation->count() === 0) {
            $result = $this->callApi($request, $format);
            $pagination_total_result_le_pagination_item_per_page = false;
            if (isset($result->pagination)) {
                if ($result->pagination->total_result <= $result->pagination->items_per_page) {
                    $pagination_total_result_le_pagination_item_per_page = true;
                }
            }
            if ($pagination !== false ||
                $pagination_total_result_le_pagination_item_per_page) {
                return $result;
            } else {
                return $this->deletePagination($request, $format, $result);
            }
        } else {
            return $validation;
        }
    }
982224
private function _setPagination(array $pagination) {
		foreach ($this->_paginationEnvelopeKeys as $key => $name) {
			$this->_pagination[$key] = isset($pagination[$name])
				? $pagination[$name]
				: null;
		}

		return $this;
	}
1252692
public function evaluate(
        QueryBuilder $queryBuilder,
        CreatePaginator $annotation
    ) {
        foreach ($this->paginatorEvaluators as $paginatorEvaluator) {
            $paginatorEvaluator->evaluate($queryBuilder, $annotation);
        }
    }
1340103
protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params )
	{
		$start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 );
		$size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 );

		$criteria->setSlice( $start, $size );
	}
298034
public function paginate()
    {
        $this->count = $this->query->get()->count();
        $this->limit = $this->limit ?: $this->count;
        $this->query->skip($this->offset)->take($this->limit);
    }
1008714
public function applyFilter(Criteria $criteria, $filter)
    {
        if (!is_array($filter) || !is_array($this->filterable)) {
            return $criteria;
        }

        foreach ($this->filterable as $field) {
            if (array_key_exists($field, $filter)) {
                $this->processEqualFilter($criteria, $field, $filter[$field]);
                $this->processBetweenFilter($criteria, $field, $filter[$field]);
                $this->processOperatorFilter($criteria, $field, $filter[$field]);
            }
        }

        return $criteria;
    }
988255
public function prepareWithPagination($statement, PaginationInterface $pagination, $driver_options = [])
    {
        $this->pagination = $pagination;

        return $this->prepare($statement, $driver_options);
    }
585095
public function paginate($limit = null, $columns = ['*'], $method = "paginate")
    {
        return parent::paginate(
            $limit,
            $this->getColumnsNames($columns),
            $method
        );
    }
766522
private function paginateRecords(ActiveQueryInterface $query, $pageNumber, $count)
    {
        $offset = ($pageNumber - 1) * $count;
        $limit = $count;

        return $query->offset($offset)->limit($limit);
    }
944965
public function countParts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collPartsPartial && !$this->isNew();
        if (null === $this->collParts || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collParts) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getParts());
            }

            $query = ChildSkillPartQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterBySkillRelatedByPartId($this)
                ->count($con);
        }

        return count($this->collParts);
    }
678345
protected function search(ModelCriteria $search, &$pagination = null)
    {
        if (false === $this->countable) {
            return $search->find();
        }

        $this->setupSearchContext($search);

        if ($this->getArgValue('page') !== null) {
            return $this->searchWithPagination($search, $pagination);
        } else {
            return $this->searchWithOffset($search);
        }
    }
391723
protected function createPaginatedQueryBuilder(array $criteria = [], $indexBy = null, array $orderBy = null)
    {
        $qb = new PaginatedQueryBuilder($this->_em);
        $qb->from($this->_entityName, $this->getEntityAlias(), $indexBy);

        $this->processCriteria($qb, $criteria);

        return $qb;
    }
1354642
public function applyToCriteriaComparator(CriteriaComparator $criteriaComparator, CriteriaProperty $alias) {
		$criteriaComparator->match($this->ci1, $this->operator, $this->ci2);
	}