resolveSearch example

$entity = $context->scope(Context::CRUD_API_SCOPE, fn (Context $context): ?Entity => $repository->search($criteria$context)->get($id));

        if ($entity === null) {
            throw ApiException::resourceNotFound($definition->getEntityName()['id' => $id]);
        }

        return $responseFactory->createDetailResponse($criteria$entity$definition$request$context);
    }

    public function searchIds(Request $request, Context $context, ResponseFactoryInterface $responseFactory, string $entityName, string $path): Response
    {
        [$criteria$repository] = $this->resolveSearch($request$context$entityName$path);

        $result = $context->scope(Context::CRUD_API_SCOPE, fn (Context $context): IdSearchResult => $repository->searchIds($criteria$context));

        return new JsonResponse([
            'total' => $result->getTotal(),
            'data' => array_values($result->getIds()),
        ]);
    }

    public function search(Request $request, Context $context, ResponseFactoryInterface $responseFactory, string $entityName, string $path): Response
    {
        [
Home | Imprint | This part of the site doesn't use cookies.