RE: [PHP4BETA] Re: [PHP3] Re: [PHP4BETA] Re: [PHP3] OO
| From: | Shannon Weyrick | Date: | Wed, 11 Aug 1999 17:01:29 +0000 |
| Subject: | RE: [PHP4BETA] Re: [PHP3] Re: [PHP4BETA] Re: [PHP3] OO | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-3342@lists.php.net to get a copy of this message | ||
On Tue, 10 Aug 1999, you wrote:
> There's no way of doing that (it's actually fairly bad OO design anyway, to
> return references to internals of your object, and have them manipulated in
> an uncontrolled manner; You can override this by directly accessing the
> object properties, though).
>
> Zeev
hmm.. well, here's the deal. I'm trying to model a form through a couple of
objects. it's laid out like this:
------
| Form |
------
|
------------------- -------------- ----------------------
| Form Entity List |--------| Form Entity |---| Input Entity Object |
| (hash of objects | | Object | | (such as textEntity, |
| with input | -------------- | checkboxEntity, etc |
| variable as key) |-------- ... ----------------------
-------------------
Now, in my main script, I start with $myForm = new $form
from there I want to say:
$myTextBox = $myForm->add('firstname','textbox');
the add() function in Form takes care of all the dirty work of creating the
necesary objects below it. but I'd like it to return a pointer to the input
entity that gets created, so that I can say
$myTextBox->setSize(20);
$myTextBox->setMaxWidth(20);
or whatever I want to do with it. right now, I can't do this, since it
returns a COPY of the object. this matters later on when I'm running the
output() function of the input entity, since the variables that got set
(setSize, setMaxWidth) ran on the copy, and not the real one.
now, you're saying I should ...
$myForm->entityList['firstname']->inputEntity->setSize(20);
$myForm->entityList['firstname']->inputEntity->setMaxWidth(20);
which works but I'd like to avoid all that extra, duplicate typing.
Does this seem reasonable?
It may seem like I'm adding a lot of extra fluff by using all these
different objects - but the above breakdown is pretty simplified from how
it's actually written. My goal is to layout the objects this way to gain ease
of adding functionality later, and still keep it very modular.
shannon weyrick (weyrick@roadsend.com),
sysadmin/programmer