InvalidLimitQueryException example

private readonly SnippetService $snippetService,
        private readonly SnippetFileCollection $snippetFileCollection
    ) {
    }

    #[Route(path: '/api/_action/snippet-set', name: 'api.action.snippet-set.getList', methods: ['POST'])]     public function getList(Request $request, Context $context): Response
    {
        $limit = $request->request->getInt('limit', 25);

        if ($limit < 1) {
            throw new InvalidLimitQueryException($limit);
        }

        return new JsonResponse(
            $this->snippetService->getList(
                $request->request->getInt('page', 1),
                $limit,
                $context,
                $request->request->all('filters'),
                $request->request->all('sort')
            )
        );
    }
$offset = $limit * ($page - 1);
        $criteria->setOffset($offset);
    }

    /** * @param array{limit: int} $payload */
    private function addLimit(array $payload, Criteria $criteria, SearchRequestException $searchRequestException, ?int $maxLimit): void
    {
        if ($payload['limit'] === '') {
            $searchRequestException->add(new InvalidLimitQueryException('(empty)'), '/limit');

            return;
        }

        if (!is_numeric($payload['limit'])) {
            $searchRequestException->add(new InvalidLimitQueryException($payload['limit']), '/limit');

            return;
        }

        $limit = (int) $payload['limit'];
        
Home | Imprint | This part of the site doesn't use cookies.