Re: sorry, wrong email address - access to object methods...
| From: | Andrei Zmievski | Date: | Tue, 22 Jan 2002 15:09:08 +0000 |
| Subject: | Re: sorry, wrong email address - access to object methods... | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2562@lists.php.net to get a copy of this message | ||
On Mon, 21 Jan 2002, Marko Kind wrote:
> TEMPLATE: {$object->foo}
>
> translates to:
>
> $object->foo();
>
> or even:
>
> $object->getProperty("foo")
>
> I would prefer the latter solution as you don't have to provide one
> accessor method per property. In this case getProperty() is responsible
> for deciding whether it's necessary to retrieve a value and how to do it.
>
> I've had a look at the Smarty classes and to me it looks like i) should
> be fairly easy to implement. ii) is much cleaner, I think, and produces
> less noise in the template...
You should take a look at ext/overload extension that I put into CVS a
couple of months ago. It lets you do exactly that. Any access to
$obj->foo gets translated to a call to object's __get() function. See
README file in the extension's directory.
-Andrei
* Ethernet n.: something used to catch the etherbunny. *