-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gii enhancement idea for model-generator #494
Comments
@yiisoft/reviewers need your opinion. |
Was one reason for me to create giiant, back then :) |
Yii 2 is quite oldschool regarding the inheritance vs composition debate so adding additional layer of inheritance would not be a terrible thing but we all know that it's not a good thing, right? ;) |
Another option would be to move the generated code into |
I remember @cebe talking about a new version that would patch the file while keeping your changes, right Carsten? |
Thanks @schmunk42 for the base model idea in giiant. Base model regeneration after modifying a database tables is something I do daily. |
yeah, that's an idea which would be really cool to implement, but I had no time to play with that. |
Hi. Sometimes it might be handy to split model into 2 classes:
UserBase contains generated code while User contains code that was produced by the programmer. The programmer can also decide to use pure PHP in model User while in UserBase can be Yii-dependent code. But it is not a rule. Code then can be more readable as classes are shorter etc.
Programmer still uses the class User as usually. No changes here.
So I am suggesting this as a new option (checkbox) in Gii.
My solution:
I extended yii\gii\generators\model\Generator and following is the result. Only method generate() was changed a little. See $this->splitModelIntoBaseClass below. (In comments are also mentioned all JS and form changes)
If you think this might be usefull for others, you can check/use my code below. But it is nothing special. Just an idea.
Good luck to yo,u Yii.
PS: Gii is amazing. When I compare it to other frameworks, you are ahead by miles as Gii is delivered directly by Yii and one has all functionalities in one bundle.
The text was updated successfully, but these errors were encountered: