I'm trying to create some logic in order to have my code better organized, so I am creating a module and trying to separate functions in different files according to it's content type.
For example, I have a module called my_module and I'm creating two content_types content_type1 and content_type2
So I created this structure:
- my_module.install
- my_module.module
- my_module.content_type1.inc
- my_module.content_type2.inc
This logic inside install:
function my_module_install() {
// During installation, the t() function is unavailable, so we use get_t()
// to store the name of the translation function.
$t = get_t();
//List of objects to be created
$nodes = array('content_type1','content_type2');
//Create all the content-types from the array
foreach ($nodes as &$node_name) {
error_log('Create: '.$node_name, 0);
call_user_func('_'.$node_name.'_create_node',$node_name);
}
unset($node_name);
}
And this logic inside each file ( content_types )
function _content_type1_create_node($node_name='type1') {}
function _content_type2_create_node($node_name='type2') {}
Since I added this lines to the my_module.info:
files[] = my_module.content_type1.inc
files[] = my_module.content_type2.inc
I was expecting to have all the logic working as it should but
//content_type1_create_node()
call_user_func('_' . $node_name . '_create_node', $node_name);
It cannot find the callback and I think it's because the callback.
Am I over engineering, or doing it wrong?