public function importCustomLayoutDefinitionAction()
{
$success = false;
$json = file_get_contents($_FILES["Filedata"]["tmp_name"]);
$importData = \Zend_Json::decode($json);
$customLayoutId = $this->getParam("id");
$customLayout = Object\ClassDefinition\CustomLayout::getById($customLayoutId);
if ($customLayout) {
try {
$layout = Object\ClassDefinition\Service::generateLayoutTreeFromArray($importData["layoutDefinitions"], true);
$customLayout->setLayoutDefinitions($layout);
$customLayout->setDescription($importData["description"]);
$customLayout->save();
$success = true;
} catch (\Exception $e) {
Logger::error($e->getMessage());
}
}
$this->removeViewRenderer();
$this->_helper->json(["success" => $success], false);
// set content-type to text/html, otherwise (when application/json is sent) chrome will complain in
// Ext.form.Action.Submit and mark the submission as failed
$this->getResponse()->setHeader("Content-Type", "text/html");
}