Re: Patch for DataObject's class generator
| From: | Torsten Roehr | Date: | Mon, 13 Dec 2004 13:51:41 +0000 |
| Subject: | Re: Patch for DataObject's class generator | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-35035@lists.php.net to get a copy of this message | ||
"Torsten Roehr" <roehr@zilleon.com> wrote in message
news:20041213132153.91700.qmail@pb1.pair.com...
> "Markus Wolff" <wolff@21st.de> wrote in message
> news:41BD93B5.1090700@21st.de...
> > Torsten Roehr wrote:
> > > with approval from Alan I have created a patch for DO's class
generator
> on
> > > top of the current CVS version to optionally generate getter and
setter
> > > methods.
> > [...]
> > > Any comments are greatly appreciated!
> >
> > Hah! We'll see about that :-)
>
> Markus, it really is! ;)
>
> > IMHO, it's a nice convenience thing to have skeleton getter/setter
> > mehotds automatically generated with the DataObjects. However, putting
> > them inside the auto-code section in the DO, which is overwritten each
> > time you run the generator (read: each time you change something in the
> > database schema) is kind of besides the point.
> >
> > When you work with setters/getters instead of raw properties, you will
> > most probably want the possibility to write some code inside of them,
> > which sets or gets your values appropriately. Having this code
> > overwritten is not really what one would wish for :-)
> >
> > So, to make this useful, these methods should either be auto-generated
> > outside the auto-code section, or, even better, you must check for the
> > existence of a method with the same name *outside the auto-code
> > section*, and if it already exists, do not generate it again. This way,
> > you could have the skeleton methods in the auto-code section and move
> > them out of there if you need to have your own code within them.
> >
> > Regards,
> > Markus
>
> This problem is something I already pointed out on PEAR general. I'll try
to
> change it to only generate methods that don't exist outside the
> auto-generated code.
The generator methods now check if the method already exists outside of the
auto-generated code and only writes it if this is not the case. The updated
files are online:
Source code: http://www.zilleon.com/PEAR/DB/DataObject/Generator.php.txt
Zip archive: http://www.zilleon.com/PEAR/DB/DataObject/Generator.zip
Sample class: http://www.zilleon.com/PEAR/DB/DataObject/Person.php.txt
Regards, Torsten