/** * @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(); if ($extensionId) { $extension = $this->db->getRepository('\\Fraym\\Block\\Entity\\BlockExtension')->findOneById($extensionId); $result = (object) $extension->toArray(1); } elseif ($id) { $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($id); if ($block) { $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); } } if ($extension) { $this->response->sendAsJson($result); } return false; }