/** * */ public function rerender() { $fileContent = $this->getFileContent('jsFileContent'); if (trim($fileContent)) { $httpFileNamePath = '/generated/' . md5($fileContent) . '.js'; $fileNamePath = 'public' . $httpFileNamePath; if (!file_exists($fileNamePath)) { file_put_contents($fileNamePath, $fileContent); } // get $doc and add the href $doc = $this->uiComposer->getDoc(); //TODO: use composer xpath? $xPath = new \DOMXpath($this->uiComposer->getDoc()); $linkElement = $xPath->query('//script[@id="js-file"]'); $linkElement->item(0)->setAttribute('src', FC::assetLink($httpFileNamePath)); } $this->needsRerender = false; }
/** * */ public function rerender() { $cssFileContent = ''; $components = $this->uiComposer->getUiComponents(); //Get all CSS file content foreach ($components as $component) { //TODO: check renderresult instead of component type if ($component instanceof HtmlWidget) { $cssFileContent .= $component->getRenderResult()->cssFileContent; } } if (trim($cssFileContent)) { // build file $cssFileContent = $this->minify($cssFileContent); $httpFileNamePath = '/generated/' . md5($cssFileContent) . '.css'; $fileNamePath = 'public' . $httpFileNamePath; if (!file_exists($fileNamePath)) { file_put_contents($fileNamePath, $cssFileContent); } // get $doc and add the href $doc = $this->uiComposer->getDoc(); //TODO: use composer xpath? $xPath = new \DOMXpath($this->uiComposer->getDoc()); $linkElement = $xPath->query('//link[@id="css-file"]'); //TODO url function missing $linkElement->item(0)->setAttribute('href', FC::assetLink($httpFileNamePath)); } $this->needsRerender = false; }