mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- optimize direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121
This commit is contained in:
@@ -677,19 +677,20 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* removed properties
|
* removed properties
|
||||||
*
|
*
|
||||||
* @var array
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private static $obsoleteProperties = array('resource_caching', 'template_resource_caching',
|
private static $obsoleteProperties = array('resource_caching', 'template_resource_caching',
|
||||||
'direct_access_security', '_dir_perms', '_file_perms',
|
'direct_access_security', '_dir_perms', '_file_perms',
|
||||||
'plugin_search_order', 'inheritance_merge_compiled_includes');
|
'plugin_search_order', 'inheritance_merge_compiled_includes');
|
||||||
|
|
||||||
private static $accessMapGet = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir',
|
/**
|
||||||
'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir',
|
* List of private properties which will call getter/setter ona direct access
|
||||||
'cache_dir' => 'getCacheDir',);
|
*
|
||||||
|
* @var array
|
||||||
private static $accessMapSet = array('template_dir' => 'setTemplateDir', 'config_dir' => 'setConfigDir',
|
*/
|
||||||
'plugins_dir' => 'setPluginsDir', 'compile_dir' => 'setCompileDir',
|
private static $accessMap = array('template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
|
||||||
'cache_dir' => 'setCacheDir',);
|
'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
|
||||||
|
'cache_dir' => 'CacheDir',);
|
||||||
|
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
@@ -1347,8 +1348,9 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
public function __get($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (isset(self::$accessMapGet[$name])) {
|
if (isset(self::$accessMap[$name])) {
|
||||||
return $this->{self::$accessMapGet[$name]}();
|
$method = 'get' . self::$accessMap[$name];
|
||||||
|
return $this->{$method}();
|
||||||
} elseif (in_array($name, self::$obsoleteProperties)) {
|
} elseif (in_array($name, self::$obsoleteProperties)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
@@ -1366,8 +1368,9 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
*/
|
*/
|
||||||
public function __set($name, $value)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
if (isset(self::$accessMapSet[$name])) {
|
if (isset(self::$accessMap[$name])) {
|
||||||
$this->{self::$accessMapSet[$name]}($value);
|
$method = 'set' . self::$accessMap[$name];
|
||||||
|
$this->{$method}($value);
|
||||||
} elseif (in_array($name, self::$obsoleteProperties)) {
|
} elseif (in_array($name, self::$obsoleteProperties)) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user