You are here

function bundle_inherit_menu_alter in Bundle Inherit 7

Implements hook_menu_alter().

File

./bundle_inherit.module, line 448
Bundle Inherit module.

Code

function bundle_inherit_menu_alter(&$items) {
  $access_callback = 'bundle_inherit_access_gate';
  foreach (entity_get_info() as $entity_type => $entity_info) {
    if ($entity_info['fieldable']) {
      foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
        if (isset($bundle_info['admin'])) {

          // Extract path information from the bundle.
          $path = $bundle_info['admin']['path'];

          // This is the position of the %field_ui_menu placeholder in the
          // items below.
          $field_position = count(explode('/', $path)) + 1;
          $items["{$path}/fields/%field_ui_menu"]['access arguments'] = array(
            $items["{$path}/fields/%field_ui_menu"]['access callback'],
            $items["{$path}/fields/%field_ui_menu"]['access arguments'],
            $field_position,
          );
          $items["{$path}/fields/%field_ui_menu"]['access callback'] = $access_callback;
          $items["{$path}/fields/%field_ui_menu/edit"]['access arguments'] = array(
            $items["{$path}/fields/%field_ui_menu/edit"]['access callback'],
            $items["{$path}/fields/%field_ui_menu/edit"]['access arguments'],
            $field_position,
          );
          $items["{$path}/fields/%field_ui_menu/edit"]['access callback'] = $access_callback;
          $items["{$path}/fields/%field_ui_menu/delete"]['access arguments'] = array(
            $items["{$path}/fields/%field_ui_menu/delete"]['access callback'],
            $items["{$path}/fields/%field_ui_menu/delete"]['access arguments'],
            $field_position,
          );
          $items["{$path}/fields/%field_ui_menu/delete"]['access callback'] = $access_callback;
          $items["{$path}/fields/%field_ui_menu/field-settings"]['access arguments'] = array(
            $items["{$path}/fields/%field_ui_menu/field-settings"]['access callback'],
            $items["{$path}/fields/%field_ui_menu/field-settings"]['access arguments'],
            $field_position,
          );
          $items["{$path}/fields/%field_ui_menu/field-settings"]['access callback'] = $access_callback;
          $items["{$path}/fields/%field_ui_menu/widget-type"]['access arguments'] = array(
            $items["{$path}/fields/%field_ui_menu/widget-type"]['access callback'],
            $items["{$path}/fields/%field_ui_menu/widget-type"]['access arguments'],
            $field_position,
          );
          $items["{$path}/fields/%field_ui_menu/widget-type"]['access callback'] = $access_callback;
          $items["{$path}/fields/%field_ui_menu/delete"]['access arguments'] = array(
            $items["{$path}/fields/%field_ui_menu/delete"]['access callback'],
            $items["{$path}/fields/%field_ui_menu/delete"]['access arguments'],
            $field_position,
          );
          $items["{$path}/fields/%field_ui_menu/delete"]['access callback'] = $access_callback;
        }
      }
    }
  }
}