Enable Smarty to handle class methods as filters, handlers etc!?
| From: | Wom.bat | Date: | Mon, 31 Mar 2003 12:16:19 +0000 |
| Subject: | Enable Smarty to handle class methods as filters, handlers etc!? | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-1054@lists.php.net to get a copy of this message | ||
Hi,
I usually use a little abstraction class to access smarty, it provides some
functions like an extended display() method, which assigns $_REQUEST, or a
constructor in which directories are set and filters are registered.
Now I have encountered the following: I want to have, for obvious reasons,
my own pre/post/output-filters, cache handler function etc. within this
abstraction class. In the case of outputfilters, this is quite easy to
manage, I can just change
$this->_plugins['outputfilter'][$function]
= array($function, null, null, false);
to
$this->_plugins['outputfilter'][((is_array($function)) ? $function[1] :
$function)]
= array($function, null, null, false);
in function register_outputfilter() in Smarty.class.php
But now, if I want to have my own cache handler (this seems not to be
possible at the moment, as $function() is used to call this one) or
prefilters, I need to keep my functions outside my class or do some deeper
hacking into Smarty.
I guess it's generally a good idea to make all of Smarty's methods, which
register any sort of function (be it a filter, or a resource handler, or a
cache handler), capable of handling class methods.
How about implementing something that is similar to most of php's functions'
capabilites to handle eiter a single function name or an array with both
class and function names in it...?
Just my 2 cents,
David