Re: [SMARTY-DEV] objects: one more approach

From: Date: Wed, 15 Jan 2003 17:11:47 +0000
Subject: Re: [SMARTY-DEV] objects: one more approach
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-545@lists.php.net to get a copy of this message
They should all work since it is just a registered variable. $foo.bar->blah $foo[section].bar->blah->hey->you Monte On Wed, 2003-01-15 at 11:04, M Mohr wrote: > Hello again, > > On Wed, Jan 15, 2003 at 10:15:45AM -0600, Monte Ohrt wrote: > > How about this. > > > > You assign objects just like variables. Let's say $foo is an assigned > > object. > > does this imply that {$foo.0->bar p1="bar} will also be supported or only > "first-level-objects" ?? > > greetings > messju > > > At first I thought about this syntax: > > > > {$foo.bar} <-- property > > {$foo.bar p1="foo" p2=$bar} <-- method > > > > But, this isn't simple because at compile time the parser doesn't know > > if $foo.bar is an array or an object, they require different syntax in > > the compiled template. I could either pass this to a function and figure > > it out at runtime (extra step), or use a separate syntax for objects: > > > > {$foo->bar} <-- property > > {$foo->bar p1="foo" p2=$bar} <-- method > > > > ok, now we know at runtime if it is an object, and how to compile it. > > Also with this syntax of passing parameters it is nothing new for the > > parser. The one problem I see is no distiction between a property and a > > method with no args. Ideas? Maybe we don't worry about it. If the method > > exists, use that. Otherwise use the property. > > > > If an object is not registered, you have access to all methods and > > properties except private ones. If registered, then restricted access to > > registered methods (but leave access to properties, or register them > > too?) > > > > I'm also wondering how the object parameters should be handled. example: > > > > {$foo->bar p1="foo" p2=$bar} > > > > which should happen? > > > > $foo->bar("foo", $bar); > > > > or > > > > $foo->bar(array('p1' => "foo", 'p2' => $bar), > > $this); > > > > Notice the second one is much like registered functions, all parameters > > are passed as an array in the first argument, and the smarty object > > passed in the second. Maybe we should do this with objects too. > > > > Monte > > > > > > -- > > Smarty Development Mailing List (http://smarty.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php -- Monte Ohrt <monte@ispi.net>

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