#[Route(path: '/api/_action/version/merge/{entity}/{versionId}', name: 'api.mergeVersion', methods: ['POST'], requirements: ['version' => '\d+', 'entity' => '[a-zA-Z-]+', 'versionId' => '[0-9a-f]{32}'])]
public function mergeVersion(Context
$context, string
$entity, string
$versionId): JsonResponse
{ $entity =
$this->
urlToSnakeCase($entity);
if (!Uuid::
isValid($versionId)) { throw ApiException::
invalidVersionId($versionId);
} $entityDefinition =
$this->
getEntityDefinition($entity);
$repository =
$this->definitionRegistry->
getRepository($entityDefinition->
getEntityName());
// change scope to be able to update write protected fields
$context->
scope(Context::SYSTEM_SCOPE,
function DContext
$context) use ($repository,
$versionId): void
{ $repository->
merge($versionId,
$context);
});
return new JsonResponse(null, Response::HTTP_NO_CONTENT
);
} #[Route(path: '/api/_action/version/{versionId}/{entity}/{entityId}', name: 'api.deleteVersion', methods: ['POST'], requirements: ['version' => '\d+', 'entity' => '[a-zA-Z-]+', 'id' => '[0-9a-f]{32}'])]