You are here

function menu_links_features_export in Features 7

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

Implements hook_features_export().

File

includes/features.menu.inc, line 162

Code

function menu_links_features_export($data, &$export, $module_name = '') {

  // Default hooks are provided by the feature module so we need to add
  // it as a dependency.
  $export['dependencies']['features'] = 'features';
  $export['dependencies']['menu'] = 'menu';

  // Collect a link to module map
  $pipe = array();
  $map = features_get_default_map('menu_links', 'menu_links_features_identifier');
  foreach ($data as $identifier) {
    if ($link = features_menu_link_load($identifier)) {

      // If this link is provided by a different module, add it as a dependency.
      if (isset($map[$identifier]) && $map[$identifier] != $module_name) {
        $export['dependencies'][$map[$identifier]] = $map[$identifier];
      }
      else {
        $export['features']['menu_links'][$identifier] = $identifier;
      }

      // For now, exclude a variety of common menus from automatic export.
      // They may still be explicitly included in a Feature if the builder
      // chooses to do so.
      if (!in_array($link['menu_name'], array(
        'features',
        'primary-links',
        'secondary-links',
        'navigation',
        'admin',
        'devel',
      ))) {
        $pipe['menu_custom'][] = $link['menu_name'];
      }
    }
  }
  return $pipe;
}