You are here

function menu_links_features_export_render in Features 6

Same name and namespace in other branches
  1. 7.2 includes/features.menu.inc \menu_links_features_export_render()
  2. 7 includes/features.menu.inc \menu_links_features_export_render()

Implementation of hook_features_export_render()

File

includes/features.menu.inc, line 236

Code

function menu_links_features_export_render($module, $data) {
  $code = array();
  $code[] = '  $menu_links = array();';
  $code[] = '';
  $translatables = array();
  foreach ($data as $identifier) {
    if ($link = features_menu_link_load($identifier)) {

      // Replace plid with a parent path.
      if (!empty($link['plid']) && ($parent = menu_link_load($link['plid']))) {
        $link['parent_path'] = $parent['link_path'];
      }
      unset($link['plid']);
      unset($link['mlid']);
      $code[] = "  // Exported menu link: {$identifier}";
      $code[] = "  \$menu_links['{$identifier}'] = " . features_var_export($link, '  ') . ";";
      $translatables[] = $link['link_title'];
    }
  }
  if (!empty($translatables)) {
    $code[] = features_translatables_export($translatables, '  ');
  }
  $code[] = '';
  $code[] = '  return $menu_links;';
  $code = implode("\n", $code);
  return array(
    'menu_default_menu_links' => $code,
  );
}