I would like to see this function in D8:

function module_include($module, $file, $dir = 'includes', $type = 'inc')

the $file parameter could be renamed to something more appropriate, but not sure what that could be
-----

I never understood why does the module_load_include has the file type as first parameter, and why is that the first parameter.

it is good to load files which look like module_name.something
like
views.module = module_load_include('module', 'views')
views.install = module_load_include('install', 'views') // but this is wrong, as module_load_install() needs to be used

but it is quite unusable for anything else:

module_load_include('inc', 'search', 'search.pages');
module_load_include('inc', 'coder_upgrade', 'includes/menu');
module_load_include('inc', 'coder_upgrade', 'conversions/list');

these should be:

module_include('search', 'search.pages', '');
module_include('search', 'pages'); // if the file would be in the right place: /includes/pages.inc
module_include('coder_upgrade', 'menu');
module_include('coder_upgrade', 'list', 'conversions');

then if the module needs it can have wrapper functions (to write less code) like

function coder_upgrade_include($file) {
   module_include('coder_upgrade', $file);
}

function coder_upgrade_include_conversion($file) {
   module_include('coder_upgrade', $file, 'conversions');
}

As I see for module_name.something I can only give two examples: module_name.module; module_name.inc
I never needed to include module_name.module, and If I create module_name.inc I always put it into the includes directory. So for me module_load_include() is a unusable function, or at least hard to write and read when I use it..
I will probably switch to ctools_include if something like this does not get into D8.

Comments

larowlan’s picture

Agree wholeheartedly. Many of my larger modules have their own wrapper to module_load_include because it is back to front.

pasqualle’s picture

actually the
modules/search/search.pages.inc can be written as

module_load_include('pages.inc', 'search');

which could be something "usable", but it is not how the api page describes it
http://api.drupal.org/api/drupal/includes--module.inc/function/module_lo...
see the node.admin.inc example

swentel’s picture

Status: Active » Closed (duplicate)

Yeah this is really a duplicate

pasqualle’s picture

Issue summary: View changes

fix code example