oCacheService = DataModelDependantCache::GetInstance(); } final public static function GetInstance(): FormsCompiler { if (!isset(static::$oInstance)) { static::$oInstance = new FormsCompiler(); } return static::$oInstance; } /** * Compile XML property tree into PHP to create the configuration form * * @param string $sXMLContent property tree structure in xml * * @return string * @throws \Combodo\iTop\Forms\Compiler\FormsCompilerException * @throws \Combodo\iTop\PropertyTree\PropertyTreeException * @throws \DOMFormatException */ public function CompileFormFromXML(string $sXMLContent): string { $oDoc = new DesignDocument(); libxml_clear_errors(); $oDoc->loadXML($sXMLContent); $aErrors = libxml_get_errors(); if (count($aErrors) > 0) { throw new FormsCompilerException('Dashlet properties definition not correctly formatted!'); } /** @var \Combodo\iTop\DesignElement $oRoot */ $oRoot = $oDoc->firstChild; $oPropertyTree = PropertyTreeFactory::GetInstance()->CreateNodeFromDom($oRoot); return $oPropertyTree->ToPHPFormBlock(); } public function StoreFormFromContent(string $sId, string $sPHPContent): void { $this->oCacheService->StorePhpContent(self::CACHE_POOL, $sId, $sPHPContent); } }