1 admin_bar.map.inc field_ui_admin_bar_map()

Implements hook_admin_bar_map() on behalf of Field UI module.

@todo Figure out how to fix the comment entity bundle mappings.

File

core/modules/admin_bar/admin_bar.map.inc, line 92
Implements hook_admin_bar_map() on behalf of core modules.

Code

function field_ui_admin_bar_map() {
  $map = array();

  foreach (entity_get_info() as $entity_type => $entity_info) {
    if (!$entity_info['fieldable']) {
      continue;
    }

    foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
      // @see field_ui_menu()
      if (!isset($bundle_info['admin'])) {
        continue;
      }

      // Check access to this bundle.
      $bundle_info['admin'] += array(
        'access callback' => 'user_access',
        'access arguments' => array('administer site configuration'),
      );
      if (!call_user_func_array($bundle_info['admin']['access callback'], $bundle_info['admin']['access arguments'])) {
        continue;
      }

      if ($fields = field_info_instances($entity_type, $bundle)) {
        $path = $bundle_info['admin']['path'];
        $argument = array();
        if (isset($bundle_info['admin']['bundle argument'])) {
          $bundle_arg = arg($bundle_info['admin']['bundle argument'], $path);
          $argument[$bundle_arg] = array($bundle);
        }
        $argument['%field_ui_menu'] = array_keys($fields);

        if (!isset($map["$path/fields/%field_ui_menu"])) {
          $map["$path/fields/%field_ui_menu"] = array(
            'parent' => "$path/fields",
            'arguments' => array(),
          );
        }
        $map["$path/fields/%field_ui_menu"]['arguments'][] = $argument;
      }
    }
  }

  return $map;
}