From: Tim Otten Date: Sat, 27 Feb 2016 00:59:05 +0000 (-0800) Subject: CRM-17570 - CRM_Core_Menu - Fire `alterMenu` hook X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7dc34fb8aca9bb88ae70475a9c6a5d29ddf0a5bb;p=civicrm-core.git 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. --- 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. *