function menu_links_features_export_render in Features 7.2
Same name and namespace in other branches
- 6 includes/features.menu.inc \menu_links_features_export_render()
- 7 includes/features.menu.inc \menu_links_features_export_render()
Implements hook_features_export_render().
File
- includes/
features.menu.inc, line 267 - Features integration for 'menu' module.
Code
function menu_links_features_export_render($module, $data, $export = NULL) {
$code = array();
$code[] = ' $menu_links = array();';
$code[] = '';
$translatables = array();
foreach ($data as $identifier) {
if ($link = features_menu_link_load($identifier)) {
// @todo Explain why empty($export) is passed as second parameter. See #3075693.
$new_identifier = menu_links_features_identifier($link, empty($export));
// Replace plid with a parent path.
if (!empty($link['plid']) && ($parent = features_menu_link_load_by_mlid($link['plid']))) {
// If the new identifier is different than the old, maintain
// 'parent_path' for backwards compatibility.
if ($new_identifier != menu_links_features_identifier($link)) {
$link['parent_path'] = $parent['link_path'];
}
else {
$clean_title = features_clean_title($parent['link_title']);
$link['parent_identifier'] = "{$parent['menu_name']}_{$clean_title}:{$parent['link_path']}";
}
}
if (isset($export)) {
// Don't show new identifier unless we are actually exporting.
$link['options']['identifier'] = $new_identifier;
// Identifiers are renewed. We need to update them in the DB.
$temp = $link;
menu_link_save($temp);
}
unset($link['plid']);
unset($link['mlid']);
$code[] = " // Exported menu link: {$new_identifier}.";
$code[] = " \$menu_links['{$new_identifier}'] = " . features_var_export($link, ' ') . ";";
$translatables[] = $link['link_title'];
}
}
$code[] = '';
if (!empty($translatables)) {
$code[] = features_translatables_export($translatables, ' ');
}
$code[] = ' return $menu_links;';
$code = implode("\n", $code);
/* @see \hook_menu_default_menu_links() */
return array(
'menu_default_menu_links' => $code,
);
}