Jump to content

best way to inherit an instantiated object?


drkstr

Recommended Posts

Hello,

I need to be able to extend an object, but all the inherited data in the child object must allread be instantiated. 

What are the best methods/practices to do this? The reason why I ask, is I am unable to use a constructor in the child. The child object needs to be formed in such a way that it can be made "callable" by client side Flash code. Constructors will break this functionality, but it will call an init() method if it exists.

Can any one recommend the best way to get the data in the child object instantiated?  If I just call the parent constructor from a method in a child object, will the inherited data in the child object be instantiated as well? Should I just get rid of the parent constructor and put it in the init() function of the child? I would prefer not to do the later since the constructor of the parent uses some private helper functions that I would have to make public.

Thanks for your time!
...drkstr
Link to comment
Share on other sites

Like I said, using a constructor in the child object breaks the Flash remoting (amfphp). I'm not sure why, but it does.

right now I am just adding a data member to the child object called myObjectVars, then in the init() method, I'm doing crating an instance of the parent:

[code]class ServiceNetworkConfig extends NetworkConfig {

  private $myObjectVars = array();

  public function init() {
    $netConfig = new NetworkConfig();
    $this->myObjectVars = get_object_vars($netConfig);
  }

  #This function will be callable by the client side Flash script.
  public function retrieveData() {
    return $this->myObjectVars;
  }
}[/code]

I don't like this though because it makes parsing the data back to the parent class difficult.

Thanks for the reply!
...drkstr
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.