Closed (won't fix)
Project:
Patterns
Version:
7.x-1.0-rc1
Component:
Code
Priority:
Minor
Category:
Task
Assigned:
Reporter:
Created:
30 Oct 2012 at 11:49 UTC
Updated:
25 Jan 2013 at 12:35 UTC
Hello everyone,
I found that there are several calls to module_load_include() in the hook menu() that could be simplified using file and and file path properties instead.
E.g.:
$first_install = variable_get(PATTERNS_FIRST_INSTALL, TRUE);
if ($first_install) {
module_load_include('inc', 'patterns', 'includes/forms/first_install');
$items['admin/patterns'] = array(
'title' => 'Patterns',
'description' => 'Patterns was just installed or important updates have been found',
'page callback' => 'patterns_first_install_page',
'access arguments' => array('administer patterns'),
);
return $items;
}
could be replaced by:
//This is just a draft!. Code has not been tested!.
$first_install = variable_get(PATTERNS_FIRST_INSTALL, TRUE);
if ($first_install) {
module_load_include('inc', 'patterns', 'includes/forms/first_install');
$items['admin/patterns'] = array(
'title' => 'Patterns',
'description' => 'Patterns was just installed or important updates have been found',
'page callback' => 'patterns_first_install_page',
'access arguments' => array('administer patterns'),
'file' => 'first_install.inc',
'file path' => drupal_get_path('patterns', 'inc'),
);
return $items;
}
The main advantage is that makes easier to track the original file the called functions belong to (more info at: http://api.drupal.org/api/drupal/modules!system!system.api.php/function/...)
I will create a branch of the code at github, take a look at it and provide a patch if everything is ok.
Cheers,
David
Comments
Comment #1
drozasComment #2
drozasThis will be gathered in the new release.