Re: [SMARTY] Registering plugins inside a class?
| From: | M Mohr | Date: | Thu, 13 Feb 2003 13:57:42 +0000 |
| Subject: | Re: [SMARTY] Registering plugins inside a class? | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7726@lists.php.net to get a copy of this message | ||
On Thu, Feb 13, 2003 at 02:32:59PM +0100, Matthias Mohr wrote:
> > > I would like to have easy access to all my class-variables and methods inside
> > > the plugin-functions.
> >
> > except for modifiers all plugin-functions get a reference to $smarty
> > supplied. you could add a property to $smarty that references your
> > application-object and access it via $smarty->app->[function or property]
> > from your plugins.
> As you said, modifiers don't get a reference.
> And I'm missing it :)
> Maybe it could be changed, that _every_ function get a reference as first parameter?
> (O.K. this would make it incompatible to older versions, but that's the price...)
>
> BTW, what exactly is that reference?
> When I derive several classes (e.g. MySmarty extends Smarty and MyOther extends MySmarty)
> to which class does it point?
> To the same from which "->display" (or "->fetch" or ...) has been
> called?
yes. there is one distinct object, whose display()-method is
called. this object may be a member of severeal classes, though.
don't mix classes and objects.
> Or always to something inside the baseclass Smarty?
>
> > > If possible, it would be a nice feature for a future version.
> > > Then it would be possible to capsulate the whole smarty application-functionality
> > > in an own class, including all the plugin-functions.
> >
> > another idea would be to add a $default_plugin_handler_func like
> > $default_template_handler_func that is called if a plugin-function
> > cannot be found. such a function could dispatch the call to the right
> > object-method. i'd like to add this to smarty. in the moment i have
> > not spare time for that but maybe in a few days.
> Hmm. Would this solve the problem with using class-functions?
> The function which dispatches the stuff must then again be a regular function and
> may not be a class-method.
yes.
> Or am I wrong?
>
> What's the reason, that Smarty could not dispatch anything to the class in which the
> object is instanciated?
> Is this a PHP limitation or is my thinking going in the wrong direction?
> (I'm relatively new to PHP :))
>
> with regards,
> Matthias
have fun
messju