Re: [SMARTY-DEV] object problems

From: Date: Wed, 22 Jan 2003 03:36:29 +0000
Subject: Re: [SMARTY-DEV] object problems
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-580@lists.php.net to get a copy of this message
From: "Monte Ohrt" <monte@ispi.net> ... > 1) register all objects and methods: > > $smarty->register('myFoo', $my, 'foo'); > > {myFoo p1="blah" p2="blah"} > > PROS: * no new syntax, looks just like a template function call. > CONS: * cannot have arrays of objects to loop over > * cannot pass object as parameter to function > * every method must be registered before hand > * property access? I'm still leaning heavily towards this model: * It doesn't introduce any new concepts for the template monkey. * It gives the developer total control over what aspects of the object API are exposed. * Method callbacks have the same API as regular Smarty function callbacks * Being unable to iterate over arrays of objects is not a con, since that whole concept of "object" won't exist at the template level. * Registering every method before hand is no big deal -- we do that anyway for functions. If we really want to support access properties (object members) we could easily just assign them: $smarty->assign("myMember", $my->member); The control is wholly in the hands of the developer where it belongs, and the template designer just uses the content. Some might argue that this is a trivial change that gives us no real benefit. However, it DOES provide a benefit for those of us who are invested in pure OO PHP development because it allows us to go directly from a Smarty template to an object function/member without going through a non-OO intermediary. -Bharat

« previous php.smarty.dev (#580) next »