/** * @param null $blockId */ public function getBlockConfig($blockId = null) { $configXml = null; if ($blockId) { $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId); $configXml = $this->blockParser->getXmlObjectFromString($this->blockParser->wrapBlockConfig($block)); } $this->imageController->getBlockConfig($configXml); }
/** * Loading the block xml configuration. Response JSON. * * @return bool */ public function getBlockConfig() { // set if the block exsists $id = $this->request->gp('id', false); // set if the block is a new one $extensionId = $this->request->gp('extensionId', false); $result = new \stdClass(); $extension = null; if ($extensionId) { $extension = $this->db->getRepository('\\Fraym\\Block\\Entity\\Extension')->findOneById($extensionId); $result = $extension->toArray(1); } elseif ($id) { $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($id); if ($block) { if ($block->changeSets->count()) { $block = $block->changeSets->last(); } $extension = $block->extension; $arrayFromXml = $this->blockParser->xmlToArray($this->blockParser->getXmlObjectFromString($this->blockParser->wrapBlockConfig($block))); $result->xml = $arrayFromXml['block']; $result = (object) array_merge($block->toArray(2), $block->extension->toArray(1), (array) $result); $result->blockName = $block->name; } } return $extension ? $this->response->sendAsJson($result) : false; }
/** * @param null $blockId */ public function getBlockConfig($blockId = null) { $configXml = null; $config = []; if ($blockId) { $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId); $configXml = $this->blockParser->getXmlObjectFromString($this->blockParser->wrapBlockConfig($block)); $config = json_decode($configXml->mailformOptions, true); } $this->mailformController->getBlockConfig($config); }
/** * @param $template * @return \SimpleXMLElement */ public function getTemplateXmlObject($template) { $template = $this->getTemplatePath() . DIRECTORY_SEPARATOR . $template; $templateContent = file_get_contents($template); $blocks = $this->blockParser->getAllBlocks($templateContent); foreach ($blocks as $block) { $obj = $this->blockParser->getXmlObjectFromString($block); if ($this->blockParser->getXmlAttr($obj, 'type') === 'config') { return $obj; } } }
/** * @Fraym\Annotation\Route("/fraym/load-dynamic-template-config", name="dynamicTemplateConfig", permission={"\Fraym\User\User"="isAdmin"}) */ public function loadDynamicTemplateConfig() { $template = $this->request->post('template'); $blockId = $this->request->post('blockId'); $variables = []; if ($blockId) { $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId); if ($block->changeSets->count()) { $block = $block->changeSets->last(); } $xml = $this->blockParser->getXmlObjectFromString($this->blockParser->wrapBlockConfig($block)); $variables = unserialize((string) $xml->dynamicTemplateConfig); } $localeResult = $this->db->getRepository('\\Fraym\\Locale\\Entity\\Locale')->findAll(); foreach ($localeResult as $locale) { $locales[] = $locale->toArray(1); } $obj = $this->dynamicTemplate->getTemplateXmlObject($template); $objTemplate = $obj ? (string) $obj->template : ''; return $this->renderConfig($objTemplate, $locales, $variables); }