Gii direct access

First let me state that I have Gii working and I’ve even been able to extend it following this guide:

There are no problems with Gii using it via the default interface.

Now I’m trying to access some of the functions of Gii via code rather than the user interface so that I can integrate them into my own user interface. My first step was to create an instance of the Gii module and then try to access the generators so I could loop through them to find the one I wanted and then proceed from there to pass it the required values and then run the prepare function to actually create the model file.

I tried:

$gii = Yii::app()->getModule('gii');


That returns:

I’m not really sure where to go from here. I guess that findGenerators isn’t really meant to be accessed this way, but how would I go about achieving the same result?

Should I just skip to using CCodeGenerator and CCodeModel somehow?


You could extend it, and thus access the protected functions. :)

How would I go about extending a module? I understand how to do it for other things like models and controllers. According to the information here:

I’ve actually done both from the tutorial I originally posted, by creating a widget as well as overriding the default model templates. But those aren’t truly extending the module, they are just extending the features without the ability to override the core.

I tried creating a new component named “xGiiModule” and copying the code from GiiModule.php in the framework folder but I’m not sure how to use it. If I try to call the any function via “xGiiModule::init()” or “xGiiModule::findGenerators()” it gives this error: