function field_ui_admin_menu_map in Administration menu 8.3
Same name and namespace in other branches
- 7.3 admin_menu.map.inc \field_ui_admin_menu_map()
Implements hook_admin_menu_map() on behalf of Field UI module.
File
- ./
admin_menu.map.inc, line 108 - Implements hook_admin_menu_map() on behalf of core modules.
Code
function field_ui_admin_menu_map() {
$map = [];
$complete_bundle_info = entity_get_bundles();
foreach ($complete_bundle_info as $entity_type => $bundles) {
foreach ($bundles as $bundle_name => $bundle_info) {
if (!isset($bundle_info['admin'])) {
continue;
}
// @see field_ui_permission()
if (user_access('administer ' . $entity_type . ' fields')) {
$fields = [];
foreach (field_info_instances($entity_type, $bundle_name) as $field) {
$fields[] = $field['field_name'];
}
if ($fields) {
$path = $bundle_info['admin']['path'];
$arguments = [];
// Extract the bundle argument name from the bundle info.
// If no bundle argument is defined, then the entity type has a single
// bundle only, in which case Field UI attaches itself to the static/
// non-dynamic path in $bundle_info['admin']['path'].
// @see field_ui_menu()
if (isset($bundle_info['admin']['bundle argument'])) {
$bundle_pos = $bundle_info['admin']['bundle argument'];
$parts = explode('/', $path);
$bundle_arg = $parts[$bundle_pos];
// Special-casing for comments.
// @todo Core: Rename 'node bundle' to 'parent bundle'.
// @todo Doesn't work yet. Why?
if ($entity_type == 'comment') {
$bundle_name = $bundle_info['node bundle'];
}
$arguments[$bundle_arg] = [
$bundle_name,
];
}
$arguments['%field_ui_instance'] = $fields;
$map["{$path}/fields/%field_ui_instance"]['parent'] = "{$path}/fields";
$map["{$path}/fields/%field_ui_instance"]['arguments'][] = $arguments;
}
}
}
}
return $map;
}