private readonly RequestCriteriaBuilder
$criteriaBuilder,
private readonly EntityProtectionValidator
$entityProtectionValidator,
private readonly AclCriteriaValidator
$criteriaValidator ) { } #[Route(path: '/api/_action/clone/{entity}/{id}', name: 'api.clone', methods: ['POST'], requirements: ['version' => '\d+', 'entity' => '[a-zA-Z-]+', 'id' => '[0-9a-f]{32}'])]
public function clone(Context
$context, string
$entity, string
$id, Request
$request): JsonResponse
{ $behavior =
new CloneBehavior( $request->request->
all('overwrites'
),
$request->request->
getBoolean('cloneChildren', true
) );
$entity =
$this->
urlToSnakeCase($entity);
$definition =
$this->definitionRegistry->
getByEntityName($entity);
$missing =
$this->
validateAclPermissions($context,
$definition, AclRoleDefinition::PRIVILEGE_CREATE
);
if ($missing) { throw ApiException::
missingPrivileges([$missing]);
} /** @var EntityWrittenContainerEvent $eventContainer */