function less_get_settings in Less CSS Preprocessor 7.4
Same name and namespace in other branches
- 8 less.module \less_get_settings()
- 7.2 less.module \less_get_settings()
- 7.3 less.module \less_get_settings()
Returns the compiled list of variables and functions for a module/theme.
Parameters
string $system_name: Module/theme system name. NULL is cast to empty string for array indexes.
1 call to less_get_settings()
- _less_attach_settings in includes/
less.process.inc - Attach LESS settings to each file as appropriate.
File
- ./
less.module, line 420 - Handles compiling of .less files.
Code
function less_get_settings($system_name = NULL) {
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['cache'] =& drupal_static(__FUNCTION__);
}
$less_settings_static =& $drupal_static_fast['cache'];
if (!isset($less_settings_static[$system_name])) {
global $theme;
$valid_module = !empty($system_name) && module_exists($system_name);
$theme_settings = theme_get_setting('less', $theme);
$defaults_cache =& drupal_static('less_defaults');
if (!isset($defaults_cache)) {
_less_registry();
}
// Defaults.
$data = array(
'build_cache_id' => _less_get_dir(),
'variables' => array(),
'functions' => array(
'token' => '_less_token_replace',
),
'paths' => array(),
LESS_AUTOPREFIXER => (bool) variable_get(LESS_AUTOPREFIXER, FALSE),
LESS_DEVEL => (bool) variable_get(LESS_DEVEL, FALSE),
LESS_SOURCE_MAPS => (bool) variable_get(LESS_SOURCE_MAPS, FALSE),
'theme' => $theme,
);
/*
* Compile the LESS variables.
*/
// Cached default variables from .info files and hook_less_variables().
if (!empty($defaults_cache[$system_name])) {
$data['variables'] = array_replace($data['variables'], array_filter($defaults_cache[$system_name]));
}
// Saved variable values from current theme.
if (!is_null($theme_settings) && !empty($theme_settings[$system_name])) {
$data['variables'] = array_replace($data['variables'], array_filter($theme_settings[$system_name]));
}
// Prevent $system_name from being altered.
$alter_system_name = $system_name;
// Invoke hook_less_variables_alter().
drupal_alter('less_variables', $data['variables'], $alter_system_name);
// Invoke hook_less_variables_SYSTEM_NAME_alter().
drupal_alter('less_variables_' . $system_name, $data['variables']);
/*
* Grab the LESS functions.
*
* LESS functions are not stored in the cache table since they could be
* anonymous functions.
*/
if ($valid_module && module_hook($system_name, 'less_functions')) {
$data['functions'] = array_replace($data['functions'], (array) module_invoke($system_name, 'less_functions'));
}
// Prevent $system_name from being altered.
$alter_system_name = $system_name;
// Invoke hook_less_functions_alter().
drupal_alter('less_functions', $data['functions'], $alter_system_name);
// Invoke hook_less_functions_SYSTEM_NAME_alter().
drupal_alter('less_functions_' . $system_name, $data['functions']);
/*
* Grab the LESS include paths.
*
*/
if ($valid_module && module_hook($system_name, 'less_paths')) {
$data['paths'] = array_unique(array_merge($data['paths'], (array) module_invoke($system_name, 'less_paths')));
}
// Prevent $system_name from being altered.
$alter_system_name = $system_name;
// Invoke hook_less_paths_alter().
drupal_alter('less_paths', $data['paths'], $alter_system_name);
// Invoke hook_less_paths_SYSTEM_NAME_alter().
drupal_alter('less_paths_' . $system_name, $data['paths']);
$data['paths'] = array_unique($data['paths']);
$less_settings_static[$system_name] = $data;
}
// Don't need to test isset(), there will always be data at $system_name.
return $less_settings_static[$system_name];
}