get_registered_object() ??
| From: | M Mohr | Date: | Fri, 14 Feb 2003 08:22:33 +0000 |
| Subject: | get_registered_object() ?? | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-691@lists.php.net to get a copy of this message | ||
Hello,
since objects cannot be passed to function as arguments and i see no
easy way to add this possibility to smarty, wouldn't it be nice to
have a function in smarty to access objects by name?
function &get_registered_object($name) {
if (isset($this->_reg_objects[$name]))
return $this->_reg_objects[$name][0];
}
this could be used inside plugins to obtain references to registered
objects without relying on smarties internal $_reg_objects structure.
for example:
{foo object=oname}...{/foo}
and in smarty_block_foo() we can do:
if (isset[$params['object']]) {
$o =& $smarty->&get_registered_object($params['object']);
// user $o here
}
so the plugins can use objects by name. similar to "item" and "key" in
{foreach}.
any opinions/comments?
regards
messju