/** @var EntityWrittenContainerEvent $eventContainer */
$eventContainer =
$context->
scope(Context::CRUD_API_SCOPE,
function DContext
$context) use ($definition,
$id,
$behavior): EntityWrittenContainerEvent
{ $entityRepo =
$this->definitionRegistry->
getRepository($definition->
getEntityName());
return $entityRepo->
clone($id,
$context, null,
$behavior);
});
$event =
$eventContainer->
getEventByEntityName($definition->
getEntityName());
if (!
$event) { throw ApiException::
noEntityCloned($entity,
$id);
} $ids =
$event->
getIds();
$newId =
array_shift($ids);
return new JsonResponse(['id' =>
$newId]);
} #[Route(path: '/api/_action/version/{entity}/{id}', name: 'api.createVersion', methods: ['POST'], requirements: ['version' => '\d+', 'entity' => '[a-zA-Z-]+', 'id' => '[0-9a-f]{32}'])]
public function createVersion(Request
$request, Context
$context, string
$entity, string
$id): Response
{