/** * Function writes the compiled output to the file system. * * @param string $compiled_source Final compiled output. * @param string $template_name Name of the template. * @return string Returns the compiled file name. */ private function _writeCompiledFile($compiled_source, $template_name) { //create directory if needed $dir = $this->_resource_manager->getTemplateDir($template_name); if (!file_exists($dir)) { mkdir($dir, 0777, true); } //create file with compiled template $filename = $this->_resource_manager->getCompiledPath($template_name); $bytes = file_put_contents($filename, $compiled_source); if ($bytes === false) { throw new Template_Exception("Error writing compiled file: {$template_name}"); } return $filename; }