Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

property setters

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
Aristophan
Smarty Regular


Joined: 10 Jan 2011
Posts: 96

PostPosted: Thu Oct 20, 2011 9:22 am    Post subject: property setters Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Oct 20, 2011 1:28 pm    Post subject: Reply with quote

You can use getter/setter on all properties. Most are currently not implemented physical but processed by an implementation inside __call().
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Thu Oct 20, 2011 1:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Aristophan
Smarty Regular


Joined: 10 Jan 2011
Posts: 96

PostPosted: Thu Oct 20, 2011 2:03 pm    Post subject: Reply with quote

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... Wink
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
View user's profile Send private message
Aristophan
Smarty Regular


Joined: 10 Jan 2011
Posts: 96

PostPosted: Thu Oct 20, 2011 2:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Thu Oct 20, 2011 2:13 pm    Post subject: Reply with quote

$smarty->use_sub_dirs = true; // property access
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP