Admin_ObjectController::deleteInfoAction PHP Метод

deleteInfoAction() публичный Метод

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