Hi,
All my table names have a prefix and some of them have suffixes too, e.g. co_country_m. Can I make DevTools generate all views in directory excluding the prefix and suffix, i.e. country.
Thanks, Amal
|
May '17 |
4 |
287 |
0 |
I'm afraid devtools has no such feature.
A hacky but fast solution would be to create a script that operates on the already generated classes, removes the pre+suffix from file and classname, and overrides with the corresponding table name in getSource()
.
Or, you can create your own models generator. I could share our repo, but it's streamlined for our project and may be useless to you :]
I don't understand. Can you explain more with an example ?
This link might be help you :
https://blog.phalconphp.com/post/tutorial-creating-a-custom-models-initializer
If you found something, can you post here your solution ?
Thanks for your prompt replies. Yes, you are perfectly right @lajosbencz, what you wrote is what I wanted to achieve. I was trying to see if I can edit the DevTools Scaffold.php
temporarily and get it to generate all the code but I get some errors - it can't find the model file. I want that the views also should use Country
in all their links. I should probably do some post processing as you suggested. Will the Phalcon router create any issues for me if I use country
everywhere - can't visualize.
If you have some tables using same prefix and suffixes, perhaps you can use Country to generate with Devtools and create a template model to extend or something like that :
class CoModel extends Phalcon\Mvc\Model
{
public function getSource()
{
return 'co_' . strtolower(get_class($this));
}
}
https://stackoverflow.com/questions/16940788/table-prefix-configuration-in-phalcon-model