definitionNotFound example

'type' => 'error',
            'reason' => 'Foo Error',
        ]]);

        static::assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $res->getStatusCode());
        static::assertEquals('ELASTICSEARCH_INDEXING', $res->getErrorCode());
        static::assertStringContainsString($res->getMessage(), 'Following errors occurred while indexing: ' . \PHP_EOL . 'Foo Error');
    }

    public function testDefinitionNotFound(): void
    {
        $res = ElasticsearchIndexingException::definitionNotFound('foo');

        static::assertEquals(Response::HTTP_BAD_REQUEST, $res->getStatusCode());
        static::assertEquals(ElasticsearchIndexingException::ES_DEFINITION_NOT_FOUND, $res->getErrorCode());
        static::assertEquals('Elasticsearch definition of foo not found', $res->getMessage());
    }
}
$indexing = new IndexingDto($ids$alias$definition->getEntityName());

        return new ElasticsearchIndexingMessage($indexing, null, $context);
    }

    private function createIndexingMessage(IndexerOffset $offset): ?ElasticsearchIndexingMessage
    {
        $definition = $this->registry->get((string) $offset->getDefinition());

        if (!$definition) {
            throw ElasticsearchIndexingException::definitionNotFound((string) $offset->getDefinition());
        }

        $entity = $definition->getEntityDefinition()->getEntityName();

        $iterator = $this->iteratorFactory->createIterator($definition->getEntityDefinition()$offset->getLastId()$this->indexingBatchSize);

        $ids = $iterator->fetch();

        if (empty($ids)) {
            if (!$offset->hasNextDefinition()) {
                return null;
            }
if ($versionId !== null && !Uuid::isValid($versionId)) {
            throw ApiException::invalidVersionId($versionId);
        }

        if ($versionName !== null && !ctype_alnum($versionName)) {
            throw ApiException::invalidVersionName();
        }

        try {
            $entityDefinition = $this->definitionRegistry->getByEntityName($entity);
        } catch (DefinitionNotFoundException $e) {
            throw ApiException::definitionNotFound($e);
        }

        $versionId = $context->scope(Context::CRUD_API_SCOPE, fn (Context $context): string => $this->definitionRegistry->getRepository($entityDefinition->getEntityName())->createVersion($id$context$versionName$versionId));

        return new JsonResponse([
            'versionId' => $versionId,
            'versionName' => $versionName,
            'id' => $id,
            'entity' => $entity,
        ]);
    }

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