1 menu.install menu_update_1001()

Move menu content type settings into configuration files.

Related topics

File

core/modules/menu/menu.install, line 70
Install, update and uninstall functions for the menu module.

Code

function menu_update_1001() {
  // Ensure module-provided code is loaded.
  backdrop_load('module', 'node');
  backdrop_load('module', 'entity');

  $node_types = node_type_get_types();
  foreach ($node_types as $node_type) {
    // Move the menu variables into each node type's config.
    $settings = array(
      'menu_options' => update_variable_get('menu_options_' . $node_type->type, array('main-menu')),
      'menu_parent' => update_variable_get('menu_parent_' . $node_type->type, 'main-menu:0'),
    );
    $node_type->settings = array_merge($node_type->settings, $settings);
    node_type_save($node_type);

    // Delete the migrated variables.
    update_variable_del('menu_options_' . $node_type->type);
    update_variable_del('menu_parent_' . $node_type->type);
  }
}