From 54a8dcd3432890e2abb07bd01e83301b64da2cc3 Mon Sep 17 00:00:00 2001 From: "monte.ohrt" Date: Mon, 8 Mar 2010 16:20:19 +0000 Subject: [PATCH] add __get() to templateCreate class --- libs/sysplugins/smarty_internal_template.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index 61603333..6db51b63 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -803,6 +803,25 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { return $this->smarty->fetch($this); } + /** + * lazy loads (valid) property objects + * + * @param string $name property name + */ + public function __get($name) + { + if (in_array($name, array('register', 'unregister', 'utility', 'cache'))) { + $class = "Smarty_Internal_" . ucfirst($name); + $this->$name = new $class($this); + return $this->$name; + } else if ($name == '_version') { + // Smarty 2 BC + $this->_version = self::SMARTY_VERSION; + return $this->_version; + } + return null; + } + /** * Takes unknown class methods and lazy loads sysplugin files for them * class name format: Smarty_Method_MethodName