Miscommunicationed is the root of all evil I tells ya
What I mean, was...
First descirbing what I condiered:
1) Front Controller - Acts like main() or WinMain() (in theory) in a C++ program...provides a single applcation entry point...and dispatches controller requests to appropriate controllers, which take care of the rest...
2) Controller - Takes care of request specifics...either using the model to pull data for rendering in a template engine, etc...or carries out tasks like manipulating the model...ie: adding a record to a database table...
Which leads me to a question:
Would say it is safe to assume there are two types of controllers:
1) View controller
2) Model controller
Both of which I guess are controller-controllers?
Anyways, back to original:
I wanted to know how you implemented front controllers I guess...
Here is what I mean:
Code: Select all
define('CTRLID_CREATE_USER', 1); // Model only controllers
define('CTRLID_UPDATE_USER', 2);
define('CTRLID_DELETE_USER', 3);
define('CTRLID_DISPLAY_USER', 4); // View only controller
$ctrl = (int)$_GET['ctrl'];
switch($ctrl){
case 'CTRLID_CREATE_USER:
include_once('./models/ctrl.user.php');
$o = new CxUserController();
$o->createUser();
break;
case 'CTRLID_UPDATE_USER:
include_once('./models/ctrl.user.php');
$o = new CxUserController();
$o->updateUser();
break;
case 'CTRLID_DELETE_USER:
include_once('./models/ctrl.user.php');
$o = new CxUserController();
$o->deleteUser();
break;
case 'CTRLID_DISPLAY_USER:
include_once('./models/ctrl.user.php');
$o = new CxUserController();
$o->displayUser();
break;
}
This way is static and requires hard coded changes...
I wanted to know if you all used a more dynamic or plugin approach to solve this problem or if you find the hardcoded bit much effort maintaining?
Cheers
