Re: Re: Add methods to object dinamically
| From: | Robert Cummings | Date: | Tue, 26 Oct 2004 18:21:56 +0000 |
| Subject: | Re: Re: Add methods to object dinamically | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200378@lists.php.net to get a copy of this message | ||
On Tue, 2004-10-26 at 14:21, Francisco M. Marzoa wrote:
> Greg Beaver wrote:
>
> > Sort of :)
> >
> > In PHP5, this will work.
>
> [...]
>
> Very nice, thanks a lot :-)
>
> >
> > However, you won't have access to private or protected data members.
>
> Damn! that's exactly what I want! :-(
>
> > It is always better to rigidly define your methods, and extend the
> > class as someone else suggested.
>
> The problem is that I need to serialize some objects to put them on a
> database, but I'll have problems when some of these objects contains
> another ones from third parties where I do not control the inheritance
> and I've not access directly to object fields.
>
> Converting the object to an array is useful for serialization, as I can
> access private and protected object member values, but I cannot
> unserialize them because I cannot wrote those members again.
>
> Never mind. I surely must rethink the matter again.
>
> Thanks a million, Greg.
Could you serialize the object then parse the serialized data yourself
and manipulate the values as an array, then re-serialize back to object
form and then unserialize as an object with modified protected/private
members? Sounds like a lot of work, but it just might bypass the whole
protected/private issue :) Not that it's generally a good thing to
bypass such things *heheh*.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'