private $smartyPluginDirs = array();
- /**
- * @var Smarty
- */
- private $smarty;
-
private $compileDir;
public function __destruct() {
*/
public function setPluginDirs($pluginDirs) {
$this->smartyPluginDirs = $pluginDirs;
- $this->smarty = NULL;
}
/**
}
/**
- * Get smarty instance.
+ * Create a Smarty instance.
*
* @return \Smarty
*/
- public function getSmarty() {
- if ($this->smarty === NULL) {
- require_once 'Smarty/Smarty.class.php';
- $this->smarty = new Smarty();
- $this->smarty->template_dir = './templates';
- $this->smarty->plugins_dir = $this->smartyPluginDirs;
- $this->smarty->compile_dir = $this->getCompileDir();
- $this->smarty->clear_all_cache();
- }
- return $this->smarty;
+ public function createSmarty() {
+ require_once 'Smarty/Smarty.class.php';
+ $smarty = new Smarty();
+ $smarty->template_dir = './templates';
+ $smarty->plugins_dir = $this->smartyPluginDirs;
+ $smarty->compile_dir = $this->getCompileDir();
+ $smarty->clear_all_cache();
+
+ // CRM-5308 / CRM-3507 - we need {localize} to work in the templates
+
+ require_once 'CRM/Core/Smarty/plugins/block.localize.php';
+ $smarty->register_block('localize', 'smarty_block_localize');
+
+ return $smarty;
}
}
public function __construct($filetype) {
$this->filetype = $filetype;
- $this->smarty = CRM_Core_CodeGen_Util_Smarty::singleton()->getSmarty();
+ $this->smarty = CRM_Core_CodeGen_Util_Smarty::singleton()->createSmarty();
$this->assign('generated', "DO NOT EDIT. Generated by CRM_Core_CodeGen");
- // CRM-5308 / CRM-3507 - we need {localize} to work in the templates
- require_once 'CRM/Core/Smarty/plugins/block.localize.php';
- $this->smarty->register_block('localize', 'smarty_block_localize');
-
if ($this->filetype === 'php') {
require_once 'PHP/Beautifier.php';
// create an instance
$this->smarty->assign_by_ref($key, $value);
}
- /**
- * Clear the smarty cache and assign default values.
- * FIXME: unused cos we no longer do evil singleton magick
- */
- protected function reset() {
- $this->smarty->clear_all_assign();
- $this->smarty->clear_all_cache();
- }
-
}