function power_menu_get_path in Power Menu 7.2
Gets the system path for the current page.
Parameters
$entity: The entity
$type: The entity type
$defined_path: Define a specific path to get the current page path
$use_cache: Get the cached path.
Return value
The system path
2 calls to power_menu_get_path()
- power_menu_set_path in ./
power_menu.module - Sets the system path to use for the active menu trail.
- power_menu_tokens in ./
power_menu.tokens.inc - Implements hook_tokens().
File
- ./
power_menu.module, line 285
Code
function power_menu_get_path($entity, $type, $defined_path = NULL, $use_cache = TRUE) {
// The cache key is the entity uri
$uri = entity_uri($type, $entity);
global $language;
$cache_key = "handler:{$language->language}:{$uri['path']}";
$cached_path = cache_get($cache_key, 'cache_power_menu');
$path = $use_cache && $cached_path ? $cached_path->data : FALSE;
if (!$path) {
// Get the active menu item
$router_item = menu_get_item($defined_path);
if (!$router_item) {
return $path;
}
// Get the alias for given item to use
$alias = drupal_get_path_alias($router_item['href']);
// Call all enabled plugins except a plugin changed the router information
foreach (power_menu_get_menu_handlers(TRUE) as $handler) {
$instance = power_menu_plugin_get_handler_instance($handler);
if ($instance) {
$path = $instance
->getMenuPathToActivate($entity, $type, $router_item, $alias);
if (!empty($path)) {
// Is a path set, do not loop over the next plugins
break;
}
}
}
cache_set($cache_key, $path, 'cache_power_menu');
return $path;
}
return $path;
}