Skip to content

Instantly share code, notes, and snippets.

@mikeyp
Created July 29, 2014 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeyp/8223aa8799b81b88a786 to your computer and use it in GitHub Desktop.
Save mikeyp/8223aa8799b81b88a786 to your computer and use it in GitHub Desktop.
Find out what item corresponds to a specific path
<?php
/**
* @file
* Provide Drush integration for finding menu router items.
*/
/**
* Implements hook_drush_help().
*/
function path_audit_drush_help($section) {
switch ($section) {
case 'drush:path-audit':
return dt('Find the menu router item that matches a given path.');
}
}
/**
* Implements hook_drush_command().
*/
function path_audit_drush_command() {
$items = array();
$items['path-audit'] = array(
'description' => "Find the menu router item that matches a given path.",
'callback' => 'drush_path_audit',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
'options' => array(
),
'examples' => array(
'drush path' => "",
),
'aliases' => array('path'),
);
return $items;
}
/**
* Return the menu path data..
*
* Before calling this we need to be bootstrapped to DRUPAL_BOOTSTRAP_FULL.
*/
function drush_path_audit($path) {
$router_item = menu_get_item($path);
$output = print_r($router_item);
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment