My test case for the Yii framework involves migrating a fairly large Prado based site with a console and multiple front ends.
I'm still familiarising myself with the way MVC is implemented in Yii, but it strikes me that my controllers folder is going to blow massively out of control. I think I'd like to delineate my controllers by the area of the site to which they're related, and then by the model to which they relate.
In the case of the console, I'm structuring it thusly:
For the console, i have ArtistConsoleController, with views for browsing and editing the artists, RegionConsoleController, with views for browsing and editing the regions, etc etc. There will be dozens of these controllers, each of which will have at least four or five reasonably complex actions.
I would like to put these in a subfolder of the /controllers folder, for EG /controllers/console/ArtistConsoleController.php and have the views in /views/console/artist/edit.php, /views/console/artist/browse.php, etc.
I know this isn't possible with the current implementation, but it is feasible from a technical perspective to implement it. The thing that I'm interested in though is whether it's a good idea to implement it from a design perspective.
Once again, I went hacking and got something together which seems to work but once again, I'm sure has a few gremlins - I don't know how it impacts theming because I haven't started to seriously play with that yet. CTheme::getViewFile() uses the controller id though, so as long as the controller id contains the subfolders (which the below changes ensure), it seems like it should work OK to me.
CWebApplication::createController($id) changes to:
<?php public function createController($id) { if($id==='') $id=$this->defaultController; $path=''; $fullId = $id; if(($pos=strrpos($id,"/"))) { $path = substr($id, 0, $pos); $id = substr($id, $pos+1); } if(preg_match('/^w+$/',$id)) { if(isset($this->controllerMap[$id])) return CConfiguration::createObject($this->controllerMap[$id],$id); else return $this->createControllerIn($this->getControllerPath($path),ucfirst($id).'Controller',$fullId); } } ?>
CWebApplication::getControllerPath() changes to:
<?php public function getControllerPath($path=null) { if($this->_controllerPath!==null) return $this->_controllerPath; else return $this->_controllerPath=$this->getBasePath().DIRECTORY_SEPARATOR.'controllers'.($path!=null ? DIRECTORY_SEPARATOR . $path : ''); } ?>