1 layout.module | layout_get_all_configs($type) |
Read all configuration files from disk of a particular layout type.
This method provides basic caching around Layout's config files.
Parameters
$type: Either "layout" or "menu_item".
Return value
array: An array of all configs for the specified type.
File
- core/
modules/ layout/ layout.module, line 1405 - The Layout module creates pages and wraps existing pages in layouts.
Code
function layout_get_all_configs($type) {
// Cache the raw config files once read.
if ($cache = cache()->get('layout:' . $type . ':config')) {
$configs = $cache->data;
}
else {
$configs = array();
$config_names = config_get_names_with_prefix('layout.' . $type . '.');
foreach ($config_names as $config_file) {
$config = config($config_file);
$data = $config->get();
$data += array(
'weight' => 0,
);
$configs[$data['name']] = $data;
}
// Sort the configs by path and weight.
backdrop_sort($configs, array(
'path' => SORT_STRING,
'weight' => SORT_NUMERIC,
));
// Put default layouts at the bottom.
if ($type === 'layout') {
$default = $configs['default'];
$admin_default = $configs['admin_default'];
unset($configs['default']);
unset($configs['admin_default']);
$configs['default'] = $default;
$configs['admin_default'] = $admin_default;
}
cache()->set('layout:' . $type . ':config', $configs);
}
return $configs;
}