Friday, December 14, 2012

Re: Baking fixtures for existing models

i would very much welcome that.
Currently baking fixtures really is a bit of a mess. Especially, if you try to do that with plugins in your app.
Due to the missing model connection it would also always bake all fixtures for all models without respect to the plugin.
So some better handling here would probably be a good idea.



Am Freitag, 14. Dezember 2012 05:55:37 UTC+1 schrieb Reuben:
I had posted something similar to this to the cakephp-core group a week or so ago, but I think it got swallowed up, so here goes.

I do a bit of work with CakePHP and legacy PHP projects.  A part of the fun with that is working in legacy table names that don't work well with the CakePHP convention.  For the most part, CakePHP handles this just fine, with the usage of Model::useTable and Model::primaryKey.

However, generating fixtures isn't quite up to scratch.  The bake shell for fixtures will only look at the table in the datasource to determine the name of the model and the fixture.  If my table name is an inappropriate comp_patient, and I've created a model called Patient, I'd like to be able to generate a fixture for Patient from the bake command, rather than have to generate a CompPatient fixture, and manually rename and update the class name.

I've started work a on plugin that will allow generation of fixtures, based on the models you already have generated in your Model directory, rather than the datasource.  The basics appear to work, but I need to generate the unit tests before it gets released to the general public.

What I'd really like to do is modify the core, as a contribution, and have the bake shell recognise if a generated model uses a table in the table list, then it should use the name of that model to generate the fixture, rather than the model name that would normally be generated from the table name.

I'm hoping this gets the attention of a CakePHP core developer or two.

Would this be a welcome addition to the core, or should I just stick with my plugin?

Regards
Reuben Helms

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate