Re: [SMARTY-DEV] get_registered_object() ??
| From: | Monte Ohrt | Date: | Fri, 14 Feb 2003 19:47:37 +0000 |
| Subject: | Re: [SMARTY-DEV] get_registered_object() ?? | ||
| References: | 1 2 3 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-696@lists.php.net to get a copy of this message | ||
I see, but how would you be passing a registered object to a function
anyways? Maybe you meant assigned objects?
Monte
On Fri, 2003-02-14 at 08:45, messju mohr wrote:
> On Fri, Feb 14, 2003 at 08:32:22AM -0600, Monte Ohrt wrote:
> > You can pass objects to functions as arguments:
> >
> > {$foo bar=$foo->bar} <-- good
> >
> > You just can't pass them as object parameters:
> >
> > {$foo->bar($foo->bar)} <-- no good
>
> yes and no :)
>
> i can pass an object as parameter, but i get a copy of it, not a
> reference to it. i cannot change any properties or call any methods
> that change the object's internal state. i will always change the
> copy, not the original.
>
> > On Fri, 2003-02-14 at 02:22, M Mohr wrote:
> > > 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
> > --
> > Monte Ohrt <monte@ispi.net>
> >
> >
> > --
> > Smarty Development Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> MIME: Elektronische Fraktur.
> Ralph Babel
--
Monte Ohrt <monte@ispi.net>