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

Is there the substitution of Smarty::instance()?

 
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 -> General
View previous topic :: View next topic  
Author Message
kkoba
Smarty n00b


Joined: 30 Apr 2013
Posts: 2

PostPosted: Tue Apr 30, 2013 6:32 am    Post subject: Is there the substitution of Smarty::instance()? Reply with quote

I want to use Smarty::instance() function, but I found that it has been deleted at 2009.
I'm looking for the substitution of Smarty::instance(), but I have not found good way.
Using global variable is not cool, I think.
Is there a good way?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Apr 30, 2013 1:31 pm    Post subject: Reply with quote

http://www.smarty.net/forums/viewtopic.php?t=16604
Back to top
View user's profile Send private message Visit poster's website
kkoba
Smarty n00b


Joined: 30 Apr 2013
Posts: 2

PostPosted: Wed May 01, 2013 3:53 pm    Post subject: Reply with quote

Thanks. It helps my hope.
Why Smarty library doesn't hold such class or function?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed May 01, 2013 5:27 pm    Post subject: Reply with quote

kkoba wrote:
Thanks. It helps my hope.
Why Smarty library doesn't hold such class or function?


It really isn't the responsibility of the template engine. You create instances however you (or your framework) wishes.
Back to top
View user's profile Send private message Visit poster's website
Lord Yggdrasill
Smarty Rookie


Joined: 31 Mar 2012
Posts: 21

PostPosted: Thu May 02, 2013 12:58 am    Post subject: Reply with quote

Well singleton is an anti-pattern, poor OOP practice. If you need an instance of Smarty object everywhere, either use dependency injection or registry.
Back to top
View user's profile Send private message
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 -> General 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