/** * 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; }