Admin_DocumentController::convertAction PHP Метод

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

public convertAction ( )
    public function convertAction()
    {
        $document = Document::getById($this->getParam("id"));
        $type = $this->getParam("type");
        $class = "\\Pimcore\\Model\\Document\\" . ucfirst($type);
        if (Tool::classExists($class)) {
            $new = new $class();
            // overwrite internal store to avoid "duplicate full path" error
            \Zend_Registry::set("document_" . $document->getId(), $new);
            $props = get_object_vars($document);
            foreach ($props as $name => $value) {
                if (property_exists($new, $name)) {
                    $new->{$name} = $value;
                }
            }
            if ($type == "hardlink" || $type == "folder") {
                // remove navigation settings
                foreach (["name", "title", "target", "exclude", "class", "anchor", "parameters", "relation", "accesskey", "tabindex"] as $propertyName) {
                    $new->removeProperty("navigation_" . $propertyName);
                }
            }
            $new->setType($type);
            $new->save();
        }
        $this->_helper->json(["success" => true]);
    }