public function deleteInfoAction()
{
$hasDependency = false;
try {
$document = Document::getById($this->getParam("id"));
$hasDependency = $document->getDependencies()->isRequired();
} catch (\Exception $e) {
Logger::err("failed to access document with id: " . $this->getParam("id"));
}
$deleteJobs = [];
// check for childs
if ($document instanceof Document) {
$deleteJobs[] = [["url" => "/admin/recyclebin/add", "params" => ["type" => "document", "id" => $document->getId()]]];
$hasChilds = $document->hasChilds();
if (!$hasDependency) {
$hasDependency = $hasChilds;
}
$childs = 0;
if ($hasChilds) {
// get amount of childs
$list = new Document\Listing();
$list->setCondition("path LIKE '" . $document->getRealFullPath() . "/%'");
$childs = $list->getTotalCount();
if ($childs > 0) {
$deleteObjectsPerRequest = 5;
for ($i = 0; $i < ceil($childs / $deleteObjectsPerRequest); $i++) {
$deleteJobs[] = [["url" => "/admin/document/delete", "params" => ["step" => $i, "amount" => $deleteObjectsPerRequest, "type" => "childs", "id" => $document->getId()]]];
}
}
}
// the object itself is the last one
$deleteJobs[] = [["url" => "/admin/document/delete", "params" => ["id" => $document->getId()]]];
}
// get the element key
$elementKey = $document->getKey();
$this->_helper->json(["hasDependencies" => $hasDependency, "childs" => $childs, "deletejobs" => $deleteJobs, "elementKey" => $elementKey]);
}