Welcome Guest, Not a member yet? Register   Sign In
Question about module usage

I am currently building an application and I have created different modules for news, pages, gallery, etc
Each module is independent of all others (except for auth module - I implemented auth as a module, don't really know if it's right or wrong, it could be just a library or driver I guess, but I liked the idea of keeping everything in modules) and can stand alone as an application (have controllers,models,views,etc).

My question is how do you handle client specifications.
I'm not talking about views and positioning or anything like that. That can be done by themes. I'm talking to changes in controller.

ClientA wants ThingA in moduleA different
ClientB wants ThingB in moduleA different
ClientC wants some and not all of the features of moduleA
ClientD is satsified with module as is

I am currently calling modules directly through the url like /module/action

Am I using modules wrong?
Should they be called from other module, client specific where overiding if needed maybe?

If I understand your problem correctly then maybe try this method.

// ./application/config/routes.php
// tested OK
  // $client = $_SESSION['counter'] % 5;

  $client = $auth_module_client;
    case 'A':  $route["default_controller"]  = "c_client_A"; break;
    case 'B':  $route["default_controller"]  = "c_client_B"; break;
    case 'C':  $route["default_controller"]  = "c_client_C"; break;
    default:   $route["default_controller"]  = "c_client_D"; break;


Thanks for sharing thoughts but not what I'm really asking.

Maybe I was not very clear.
I'm talking about DRY and how to handle different client specifications like the ones stated above.

Example for more clarification.


ClientA wants function 1 behave like function 1 with additions
ClientB wants function 1 behave like function 1 with removing stuff
ClientC wants function 2 behave like function 2 with additions
ClientD wants no modifications (ideal client!)

How should I handle Module1 and it's functions so that upgrading is not a nightmare!

This would be best suited to be checked in your MY_Controller so that you will need too only update it in one place, either that or create a library and do your checking there!



func_get_args looks quite interesting in the way that it could provide me with method overloading and maybe in conjunction with the reflection API it could help in models too.

This [url|http://www.php.net/manual/en/function.func-get-args.php#85354](first) example[/url] shows a way to get polymorphic/"overloaded" function which is quite helpful in my situation.

Also since I have different schema for multilingual and single language sites (for db optimization) this [url|http://www.php.net/manual/en/function.func-get-args.php#78583](second) example[/url] shows how I could load a different class (model) based on constructor arguments which is quite nice too, although I could solve this issue with the previous example and accordingly load the appropriate model but that wouldn't be really dry (there should be a base model and client models in this case extend or override base model).

To conclude controllers would use "overload example" above to do extended tasks and lead to a _base_function which would be the non changed one (more basic implementation I suppose). As for second example I might try it in order to have different schema model (currently there is one model with conditional schema but it's bloating code) and keep models a little more clean and independent. Otherwise I'll load different model according to first example.

Got to keep on RnD.

Thanks InsiteFX. I think my solution is somewhere there.

Of course if anyone has another suggestion I'm all ears Smile

Theme © iAndrew 2016 - Forum software by © MyBB