public function copyRewriteIdsAction()
{
$transactionId = $this->getParam("transactionId");
$idStore = Session::useSession(function ($session) use($transactionId) {
return $session->{$transactionId};
}, "pimcore_copy");
if (!array_key_exists("rewrite-stack", $idStore)) {
$idStore["rewrite-stack"] = array_values($idStore["idMapping"]);
}
$id = array_shift($idStore["rewrite-stack"]);
$document = Document::getById($id);
if ($document) {
// create rewriteIds() config parameter
$rewriteConfig = ["document" => $idStore["idMapping"]];
$document = Document\Service::rewriteIds($document, $rewriteConfig, ["enableInheritance" => $this->getParam("enableInheritance") == "true" ? true : false]);
$document->setUserModification($this->getUser()->getId());
$document->save();
}
// write the store back to the session
Session::useSession(function ($session) use($transactionId, $idStore) {
$session->{$transactionId} = $idStore;
}, "pimcore_copy");
$this->_helper->json(["success" => true, "id" => $id]);
}