public function load(RequestInterface $request) { if (file_exists($this->getTemplate()) != false) { $view = ViewModel::getInstance($request); if (is_array($this->getParameters()) == true) { $view->import($this->getParameters()); } ob_start(); include_once $this->getTemplate(); $pageContent = ob_get_contents(); ob_end_clean(); return $pageContent; } else { throw new WebException(MessageCode::WEB_VIEW_DIRECTORY_NOT_FOUND); } }
public function load(RequestInterface $request) { $xmlFilePath = str_replace(Template::PHP_EXTENSION, Template::XML_EXTENSION, $this->getTemplate()); if (file_exists($this->getTemplate()) != false && file_exists($xmlFilePath) != false) { $xmlTemplateTranslator = new XmlTemplateTranslator($this->getTemplate(), $xmlFilePath); $compiledXmlDirectory = Configuration::read(ConfigurationParameters::APPLICATION_XML_VIEW_DIRECTORY); $compiledXmlFile = $compiledXmlDirectory . md5($this->getTemplate() . time()) . Template::PHP_EXTENSION; $handle = fopen($compiledXmlFile, "w"); fwrite($handle, $xmlTemplateTranslator->translate()); fclose($handle); $view = ViewModel::getInstance($request); if (is_array($this->getParameters()) == true) { $view->import($this->getParameters()); } ob_start(); include_once $compiledXmlFile; $pageContent = ob_get_contents(); ob_end_clean(); unlink($compiledXmlFile); return $pageContent; } else { throw new WebException(MessageCode::WEB_VIEW_DIRECTORY_NOT_FOUND); } }