12 March 2024

In Drupal 7, there isn't a specific function provided by the core API to directly fetch all hook_menu() items from the database. However, you can achieve this by querying the menu_router table as demonstrated in the code snippet.

Source code viewer
  1. $items = array();
  2.  
  3. // Get all menu items from the database.
  4. $query = db_select('menu_router', 'm');
  5. $query->fields('m');
  6. $result = $query->execute();
  7.  
  8. // Fetch menu items and add them to the array.
  9. foreach ($result as $item) {
  10. $items[$item->path] = (array) $item;
  11. }
  12.  
  13. dpm($items);
Programming Language: PHP