src/DataProvider/Pagination.php
public function getLimit(string $resourceClass = null, string $operationName = null, array $context = []): int
    {
        $graphql = $context['graphql'] ?? false;

        $limit = $this->options['items_per_page'];
        $clientLimit = $this->options['client_items_per_page'];

        if (null !== $resourceClass) {
            $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
            $limit = $resourceMetadata->getCollectionOperationAttribute($operationName, 'pagination_items_per_page', $limit, true);
            $clientLimit = $resourceMetadata->getCollectionOperationAttribute($operationName, 'pagination_client_items_per_page', $clientLimit, true);
        }

        if ($graphql && null !== ($first = $this->getParameterFromContext($context, 'first'))) {
            $limit = $first;
        }

        if ($graphql && null !== ($last = $this->getParameterFromContext($context, 'last'))) {
            $limit = $last;
        }

        if ($graphql && null !== ($before = $this->getParameterFromContext($context, 'before'))
            && (false === ($before = base64_decode($before, true)) ? 0 : (int) $before - $limit) < 0) {
            $limit = (int) $before;
        }

        if ($clientLimit) {
            $limit = (int) $this->getParameterFromContext($context, $this->options['items_per_page_parameter_name'], $limit);
            $maxItemsPerPage = $this->options['maximum_items_per_page'];

            if (null !== $resourceClass) {
                $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
                $maxItemsPerPage = $resourceMetadata->getCollectionOperationAttribute($operationName, 'maximum_items_per_page', $maxItemsPerPage, true);
            }

            if (null !== $maxItemsPerPage && $limit > $maxItemsPerPage) {
                $limit = $maxItemsPerPage;
            }
        }

        if (0 > $limit) {
            throw new InvalidArgumentException('Limit should not be less than 0');
        }

        return $limit;
    }
public function getLimit(string $resourceClass = null, string $operationName = null, array $context = []): int
    {
        $graphql = $context['graphql'] ?? false;

        $limit = $this->options['items_per_page'];
        $clientLimit = $this->options['client_items_per_page'];

        if (null !== $resourceClass) {
            $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
            $limit = $resourceMetadata->getCollectionOperationAttribute($operationName, 'pagination_items_per_page', $limit, true);
            $clientLimit = $resourceMetadata->getCollectionOperationAttribute($operationName, 'pagination_client_items_per_page', $clientLimit, true);
        }

        if ($graphql && null !== ($first = $this->getParameterFromContext($context, 'first'))) {
            $limit = $first;
        }

        if ($graphql && null !== ($last = $this->getParameterFromContext($context, 'last'))) {
            $limit = $last;
        }

        if ($graphql && null !== ($before = $this->getParameterFromContext($context, 'before'))
            && (false === ($before = base64_decode($before, true)) ? 0 : (int) $before - $limit) < 0) {
            $limit = (int) $before;
        }

        if ($clientLimit) {
            $limit = (int) $this->getParameterFromContext($context, $this->options['items_per_page_parameter_name'], $limit);
            $maxItemsPerPage = $this->options['maximum_items_per_page'];

            if (null !== $resourceClass) {
                $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
                $maxItemsPerPage = $resourceMetadata->getCollectionOperationAttribute($operationName, 'maximum_items_per_page', $maxItemsPerPage, true);
            }

            if (null !== $maxItemsPerPage && $limit > $maxItemsPerPage) {
                $limit = $maxItemsPerPage;
            }
        }

        if (0 > $limit) {
            throw new InvalidArgumentException('Limit should not be less than 0');
        }

        return $limit;
    }
public function getLimit ( string $ resourceClass = null , string $ operationName = null , array $ context = [ ] ) : int { $ graphql = $ context [ 'graphql' ] ?? false ; $ limit = $ this -> options [ 'items_per_page' ] ; $ clientLimit = $ this -> options [ 'client_items_per_page' ] ; if ( null !== $ resourceClass ) { $ resourceMetadata = $ this -> resourceMetadataFactory -> create ( $ resourceClass ) ; $ limit = $ resourceMetadata -> getCollectionOperationAttribute ( $ operationName , 'pagination_items_per_page' , $ limit , true ) ; $ clientLimit = $ resourceMetadata -> getCollectionOperationAttribute ( $ operationName , 'pagination_client_items_per_page' , $ clientLimit , true ) ; } if ( $ graphql && null !== ( $ first = $ this -> getParameterFromContext ( $ context , 'first' ) ) ) { $ limit = $ first ; } if ( $ graphql && null !== ( $ last = $ this -> getParameterFromContext ( $ context , 'last' ) ) ) { $ limit = $ last ; } if ( $ graphql && null !== ( $ before = $ this -> getParameterFromContext ( $ context , 'before' ) ) && ( false === ( $ before = base64_decode ( $ before , true ) ) ? 0 : ( int ) $ before - $ limit ) < 0 ) { $ limit = ( int ) $ before ; } if ( $ clientLimit ) { $ limit = ( int ) $ this -> getParameterFromContext ( $ context , $ this -> options [ 'items_per_page_parameter_name' ] , $ limit ) ; $ maxItemsPerPage = $ this -> options [ 'maximum_items_per_page' ] ; if ( null !== $ resourceClass ) { $ resourceMetadata = $ this -> resourceMetadataFactory -> create ( $ resourceClass ) ; $ maxItemsPerPage = $ resourceMetadata -> getCollectionOperationAttribute ( $ operationName , 'maximum_items_per_page' , $ maxItemsPerPage , true ) ; } if ( null !== $ maxItemsPerPage && $ limit > $ maxItemsPerPage ) { $ limit = $ maxItemsPerPage ; } } if ( 0 > $ limit ) { throw new InvalidArgumentException ( 'Limit should not be less than 0' ) ; } return $ limit ; }
Gets the current limit.

@throws InvalidArgumentException
Gets the current limit .