Where do i call that onbeginrequest thing? It needs to be loaded (of course!!) before the news module is loaded, because it cant find the news module as it isn’t set in the url rules. But how do i add ‘automaticly’ these rules to the urlmanager? I dont want to manualy add these rules to the config file every time i (or some newbe who cant script at all!) install a module.
But, i want to make my modules completely independend. So this means that i do NOT want to set the url rules of the news module inside the application config file. Thats a bit weird right? So, how do i ‘add’ new urlRules to the existing ones, without having to call the whole module in the complete application.
Do i need to create a urlrules file for each module, inside that particular module? I have no idea where to start. Even the topic i posted above, i dont understand it. Is there some kind of example about this?\
And this brings me to another big question i have. Do i really have to ‘register’ the modules manualy inside the config file? what if i want to make my application ‘modular’ for noobs? What if i want my customer to be able to just drop my created module inside the modules directory, and install it from a ‘backend’ panel. After that, it should just work. I do not want them to open up/copy any php config files by hand…
The simplest way I can suggest to you is to create a little function and put it in a config file. This function should scan you modules’ directory and append an existing config array (modules, url rules, imports, …) with values defined in these modules’ config files.
Yii uses the Observer pattern to provide an event-driven system similar to the PRADO framework.
The online definitive guide docs and the PDF version have different content. Event components are described in the PDF file. From what I can understand, it appears that a component needs to be created extended from CEvent and that component must be preloaded in the main.php config file. I find this a bit odd since modules should contain all files required to use the module. I would imagine that the Event component could be stored in the module’s components/ directory and preloaded from that directory in main.php.
The onbeginRequest($event) method is at line 166 of CApplication. CApplication processes incoming requests. The $event parameter is a CEvent object type, and CEvent is extended from CComponent. If you read about application life cycles in the definitive guide, onbeginRequest and onEndRequest are breifly mentioned there and this will give you a basic idea of the general application flow as a request is processed.
The onBeginRequest and onEndRequest methods are basically hook points in the application life cycle. A hook point in the life cycle allows additional actions to be performed as part of the normal application life cycle.