resourceNotFound example

// trigger acl validation         $missing = $this->criteriaValidator->validate($definition->getEntityName()$criteria$context);
        $permissions = array_unique(array_filter(array_merge($permissions$missing)));

        if (!empty($permissions)) {
            throw ApiException::missingPrivileges($permissions);
        }

        $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));

        


    public function testDeleteLiveVersion(): void
    {
        $exception = ApiException::deleteLiveVersion();

        static::assertInstanceOf(LiveVersionDeleteException::class$exception);
    }

    public function testResourceNotFound(): void
    {
        $exception = ApiException::resourceNotFound('order', []);

        static::assertInstanceOf(ResourceNotFoundException::class$exception);
    }

    public function testUnsupportedOperation(): void
    {
        $exception = ApiException::unsupportedOperation('invalid_operation');

        static::assertEquals(ApiException::API_UNSUPPORTED_OPERATION_EXCEPTION, $exception->getErrorCode());
        static::assertEquals('Unsupported invalid_operation operation.', $exception->getMessage());
    }

    
Home | Imprint | This part of the site doesn't use cookies.