When developing a website in EE, I often create custom modules to accomplish some task, such as processing a custom form, etc. I started creating 'actions' for each form, but this grew inconvenient during development, because I would have to uninstall/reinstall, or write some 'update' code, to incorporate new action_ids (or manually add them to the exp_actions table.
My current workaround is, for any new module, to create one catch-all 'action'. So if my module was called 'Module', my action would be called 'module_do'. In my mod.module.php file, I would declare that function like so:
function mailchimp_api_do(){
$function = $this->EE->input->get_post('function',TRUE);
$accepted_functions = array(
'do_that_one_thing_you_do',
'do_that_other_thing_you_do'
);
if(in_array($function,$accepted_functions)){
//call that function
$this->$function();
}
}
That way, I could code up my forms to post to a URL like, for instance:
/?ACT=##&function=do_that_one_thing_you_do
/?ACT=##&function=do_that_other_thing_you_do
But if I used a function not in my $accepted_function
array, like:
/?ACT=##&function=do_something_you_dont_do
Nothing would happen.
So, as I build out my site, I could add new actions, sort of, by just adding to that $accepted_functions
array, and using &function=my_new_function
in my URLs...
This has worked nicely for me, and I haven't yet developed any modules that are out in the wild for others to use. My question is, is this a bad practice, or are there any reasons this is bad form, or unsecure?
Thanks!