|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Thu Oct 20, 2011 9:22 am Post subject: property setters |
|
|
Hi
Reading this forum, the Readme and possible others, I discovered the use of some setters (apart from the big 5, setFooDir) without any official use, since running a search in 3.1.4 (not sure I catched them all) I can't find them, except these 2 README examples.
Code: | Search "setDebugging" (0 hits in 0 files)
Search "setCaching" (1 hits in 1 files)
/libs/Smarty/314/README (1 hits)
Line 130: $smarty->setCaching(true); // set $smarty->caching
Search "setForceCompile" (0 hits in 0 files)
Search "setCacheId" (1 hits in 1 files)
/libs/Smarty/314/README (1 hits)
Line 132: $smarty->setCacheId($id); // set $smarty->cache_id
Search "setCacheLifetime" (0 hits in 0 files)
Search "setCompileCheck" (0 hits in 0 files)
Search "setUseSubDirs" (0 hits in 0 files)
|
If used in forum, they have never been contradicted.
So my question is: Is there any hidden function allowing these properties and is it up to the users to use them or not? Are there even more? Or is it just a foretaste of what is to come in future? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Oct 20, 2011 1:28 pm Post subject: |
|
|
You can use getter/setter on all properties. Most are currently not implemented physical but processed by an implementation inside __call(). |
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Thu Oct 20, 2011 1:54 pm Post subject: |
|
|
Since we haven't really decided upon the configuration API to go with, Smarty currently allows you to use them all. Code: | $smarty->use_sub_dirs = true;
// is the same as
$smarty->setUseSubDirs(true);
// and
echo $smarty->use_sub_dirs;
// is the same as
echo $smarty->getUseSubDirs(); |
Even if we introduced a new approach, say Code: | $smarty->setOption('use_sub_dirs', true); | the old accessors would still work to maintain backward compatibility.
If you're accessing the configuration options frequently, I'd (currently) suggest going with the property access (for performance reasons). _________________ Twitter |
|
Back to top |
|
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Thu Oct 20, 2011 2:03 pm Post subject: |
|
|
U.Tews wrote: | You can use getter/setter on all properties. Most are currently not implemented physical but processed by an implementation inside __call(). |
I see! Thank you. That is why I could not find it...
Then every property foo_bar = (true/false/array/string/CONST) can be also set to (get)setFooBar(true/false/array/string/CONST), right?
So which one is the most futureress and best performing recommendation to use? With or without the getter/setter on all properties? |
|
Back to top |
|
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Thu Oct 20, 2011 2:12 pm Post subject: |
|
|
rodneyrehm wrote: | .... suggest going with the property access (for performance reasons). |
Oh sorry I missed your comment with my last answer.
Erm..., which one do you mean by ...going with the property access? |
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Thu Oct 20, 2011 2:13 pm Post subject: |
|
|
$smarty->use_sub_dirs = true; // property access _________________ Twitter |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|