For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > June 2006 > Re: [PEAR] Wiki - Configuring dataobject_formbuilder









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] Wiki - Configuring dataobject_formbuilder
brian ally

2006-06-01, 8:00 am

Michel D'HOOGE wrote:
> I just read the wiki page on configuring DB_FB and wonder if the first
> example is correct...
> http://pear.reversefold.com/dokuwik...ing_formbuilder
>
> It is written there that the first method to configure FB is "by setting
> member variables in an extended class". Then all the other described
> methods should be able to override these settings. However the constructor
> is defined as follows:
>
> function DB_DataObject_FormBuilder_MyDriver(&$do, $options = false) {
> parent::DB_DataObject_FormBuilder($do, $options);
> $this->linkDispayLevel = 2;
> $this->elementTypeMap['date'] = 'myDate';
> }
>
> And thus the child class modifies the variables once the parent constructor
> returns, cancelling any modifications. According to me, the constructor
> should look like:
>
> function DB_DataObject_FormBuilder_MyDriver(&$do, $options = false) {
> $this->linkDispayLevel = 2;
> $this->elementTypeMap['date'] = 'myDate';
> parent::DB_DataObject_FormBuilder($do, $options);
> }
>
> Any comment?
> Michel
>


You have it backwards. If the parent constructor were to be called after
local (child) params were set, the parent would over-ride those
settings. But this isn't what you would generally want, when extending a
class.

If you were to do it your way, your child object would be
indistinguishable from a parent object (save for any child class methods
which might be available).

It's early, so perhaps i've missed something here, though.

brian
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com