From 7dc34fb8aca9bb88ae70475a9c6a5d29ddf0a5bb Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 26 Feb 2016 16:59:05 -0800 Subject: [PATCH] CRM-17570 - CRM_Core_Menu - Fire `alterMenu` hook The `xmlMenu` hook requires a literal XML file. The `alterMenu` exposes the live data structure, so that you can more easily mix in data from other sources. --- CRM/Core/Menu.php | 2 ++ CRM/Utils/Hook.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php index e100d996c9..588bac05db 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -94,6 +94,8 @@ class CRM_Core_Menu { foreach ($files as $file) { self::read($file, self::$_items); } + + CRM_Utils_Hook::alterMenu(self::$_items); } return self::$_items; diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index b06a0607f8..4123e7971d 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -518,6 +518,21 @@ abstract class CRM_Utils_Hook { ); } + /** + * (Experimental) This hook is called when build the menu table. + * + * @param array $items + * List of records to include in menu table. + * @return null + * the return value is ignored + */ + public static function alterMenu(&$items) { + return self::singleton()->invoke(1, $items, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + 'civicrm_alterMenu' + ); + } + /** * This hook is called for declaring managed entities via API. * -- 2.25.1