You are here

function content_menu_links_features_export_render in Default Content 7

Same name and namespace in other branches
  1. 7.2 defaultcontent.features.inc \content_menu_links_features_export_render()

Implements hook_features_export_render().

File

./defaultcontent.features.inc, line 109
Handles all features exporting functionality

Code

function content_menu_links_features_export_render($module, $data) {
  module_load_include('inc', 'features', 'includes/features.menu');
  $code = array();
  $code[] = '  $menu_links = array();';
  $code[] = '';
  $translatables = array();
  foreach ($data as $identifier) {
    $identifier = defaultcontent_alter_identifier($identifier, FALSE);
    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'] = defaultcontent_alter_path($parent['link_path']);
      }
      unset($link['plid']);
      unset($link['mlid']);
      $link['link_path'] = defaultcontent_alter_path($link['link_path']);
      $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(
    'content_menu_links_defaults' => $code,
  );
}