Can I use classes with register_resource?
| From: | Martin Braun | Date: | Tue, 28 Oct 2003 18:33:02 +0000 |
| Subject: | Can I use classes with register_resource? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-10456@lists.php.net to get a copy of this message | ||
hi,
I am trying to insert custom resource handlers into smarty; not as a plugin, but from within my script.
i followed the instructions in the smarty 2.5.0 manual, and it worked.
BUT: i would like to use class methods instead of functions.
basically, this is what i want (but can't do):
------ code ---------
class SmartyResource
{
function GetTemplate($tpl_name, &$tpl_source, &$smarty_obj)
{/* stuff */}
function GetTimestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
{}
function GetSecure($tpl_name, &$smarty_obj)
{
return true;
}
function GetTrusted($tpl_name, &$smarty_obj)
{
return true;
}
}
// in script:
$res = new SmartyResource();
$smarty = new Smarty();
// this won't work, of course - but can it?
$smarty->register_resource('kjc',
array("$res->GetTemplate",
"$res->GetTimestamp",
"$res->GetSecure",
"$res->GetTrusted"));
---- end code ----
does anyone know a way of accomplishing this? using a class would make things pretty easy for me and keep my code OO-only.
any help is appreciated!
thanks,
martin
--
Shall we hit it and quit? Yeah, hit it and quit? OK?
Hit it!