Closed GoogleCodeExporter closed 8 years ago
Welcome 2ben.dahai.
This Idea is good and something i haven't thought about yet. This would use the
Power of OOP a lot. Do you have a reference implementation ready for that? I
don't think it would be that difficult, one just needs to choose which
functions are being genereated into the Base classes, and which in the
overloading classes, or am i missing something?
Original comment by thyseus
on 4 Aug 2010 at 8:08
Hi Thyseus,
I'm Alban by the way, I'm on IRC from time to time :) I'm glad you like the
idea! I don't have a reference implementation now, but basically you're right,
it's mostly just changing the current output file to Base (except maybe
behaviors which would go to the overloading class), and generate the
overloading class at first generation with almost nothing inside except the
basic class declaration with the proper "extends MyObjectBase" statement.
I attach hereunder a sample class generated by Doctrine in Symfony following
this idea. It's just to give an idea, not to turn gii into Doctrine ;)
Original comment by 2ben.da...@gmail.com
on 5 Aug 2010 at 2:59
Attachments:
please take a look at R71
http://code.google.com/p/gii-template-collection/source/detail?r=71
what do you think about that?
Original comment by thyseus
on 5 Aug 2010 at 10:58
OK I tried the generation and it seems to work well, then I tried to add one
column to a table and regenerate, it seems to be working too :)
Maybe 2 small improvements:
- generate the base classes in a base sub-folder of models/ so it's a bit more
tidy when writing code
- in the gii preview, could you make it that the base classes are preselected
for overwriting ?
I'm very impressed to see this improvement has been done in such little time,
this it really cool :) Thanks a lot !
Original comment by 2ben.da...@gmail.com
on 6 Aug 2010 at 6:22
Hello,
I support the idea of separating base classes in models/base, but then gtc must
ask the user to add an import in the configuration file, like
'import' => array(
'application.models.base.*',
...
),
I have also opened issue 6 and issue 7 for other related issues.
And congratulations and thanks for gtc!
Original comment by rodrigo.coelho@gmail.com
on 2 Sep 2010 at 7:59
That's fixed, isn't it?
Original comment by schm...@usrbin.de
on 9 Sep 2010 at 1:30
It is not finished if the base models are going to be placed on models/base
directory.
Original comment by rodrigo.coelho@gmail.com
on 9 Sep 2010 at 1:49
i renamed the base model from ModelBase to BaseModel so that the Base models
are ordered together in the directory listing. This way we no longer need to
have an extra separate base/ directory. It also avoids to have that additional
'import' line in the application configuration. i propose to close this issue
as it is.
Original comment by thyseus
on 9 Sep 2010 at 2:24
My vote is to separate base models to make it cleaner in projects with lots of
models.
Original comment by rodrigo.coelho@gmail.com
on 9 Sep 2010 at 5:33
Original issue reported on code.google.com by
2ben.da...@gmail.com
on 4 Aug 2010 at 12:06