function menu_links_features_identifier in Features 7.2
Same name and namespace in other branches
- 6 includes/features.menu.inc \menu_links_features_identifier()
- 7 includes/features.menu.inc \menu_links_features_identifier()
Callback for generating the menu link exportable identifier.
Long ago, the identifier used to be "{$menu_name}:{$link_path}". Nowadays, it is "{$menu_name}_{$clean_title}:{$link_path}", reducing the chance that two menu links would have the same identifier.
@todo Verify this exact behavior. See #3075693.
Parameters
array $link: A raw menu link, e.g. from features_menu_link_load(), or from data exported in a features hook.
bool $old: See below in "return" section.
Return value
string|false The identifier, or FALSE if an identifier cannot be built for the link. If $old is TRUE:
- If $link['options']['identifier'] already contains a value (that was added there in the past), this stored identifier is returned.
- If the old-style identifier "{$menu_name}:{$link_path}" does not clash with other menu links, this old-style identifier will be returned.
- Otherwise, a new-style identifier "{$menu_name}_{$clean_title}:{$link_path}" will be returned.
If $old is FALSE:
- A new-style identifier "{$menu_name}_{$clean_title}:{$link_path}" will be returned.
See also
4 calls to menu_links_features_identifier()
- menu_links_features_export in includes/
features.menu.inc - Implements hook_features_export().
- menu_links_features_export_options in includes/
features.menu.inc - Implements hook_features_export_options().
- menu_links_features_export_render in includes/
features.menu.inc - Implements hook_features_export_render().
- menu_links_features_rebuild_ordered in includes/
features.menu.inc - Generate a depth tree of all menu links.
1 string reference to 'menu_links_features_identifier'
- menu_links_features_export in includes/
features.menu.inc - Implements hook_features_export().
File
- includes/
features.menu.inc, line 196 - Features integration for 'menu' module.
Code
function menu_links_features_identifier($link, $old = FALSE) {
// Add some uniqueness to these identifiers, allowing multiple links with the
// same path, but different titles.
$clean_title = features_clean_title($link['link_title']);
// The old identifier is requested.
if ($old) {
// If identifier already exists.
if (isset($link['options']['identifier'])) {
return $link['options']['identifier'];
}
else {
$identifier = isset($link['menu_name'], $link['link_path']) ? "{$link['menu_name']}:{$link['link_path']}" : FALSE;
// Checking if there are multiples of this identifier.
if (features_menu_link_load($identifier) !== FALSE) {
// This is where we return the upgrade posibility for links.
return $identifier;
}
}
}
return isset($link['menu_name'], $link['link_path']) ? "{$link['menu_name']}_{$clean_title}:{$link['link_path']}" : FALSE;
}