I'm running into a problem working around limitations in Zend Framework 1.x and I can't replace or update it at the moment. I have a novel idea but I'm not sure if it's possible.
The basic question is Is it possible to instantiate an extending child object, but then extract the parent object afterward for serialization?
To illustrate why, essentially the Zend_Mail
class has some really stupid limitations and type checks on its methods, in my case specifically $mail->setType()
.
My thought is that I can create an extending class (My_Zend_Mail extends Zend_Mail
), then override the setType() {...}
method in my class, eliminating the restrictions, allowing me to set certain protected
properties in the Zend_Mail
class. The limitation is that I need to hand this off to a remote server as a serialized object, and that remote server will NOT have or recognize the My_Zend_Mail
class when it's unserialized. So I need to serialize only the Zend_Mail
parent at my end.
So back to the original question, can I extract a parent object, after it's been instantiated via an extending child?
EDIT: I've found the following question whose selected answer proposes a hackish way to recast a serialized string so that it unserializes as a different object....
Convert/cast an stdClass object to another class
This might work, though further down it looks like someone is doing this via the Reflection class as well, which is closer to what I'm looking for. I might give that a shot and report back, unless there are other suggestions?