compucorp / civibooking

CiviBooking is a CiviCRM extension defining a resource booking application that runs on top of the CiviCRM platform.
Other
19 stars 44 forks source link

CGP-558: Move Menu Items to Upgrader #170

Closed MiyaNoctem closed 6 years ago

MiyaNoctem commented 6 years ago

Overview

CiviBooking currently uses a CiviCRM hook to create all menu items. This makes menu management difficult (user cannot move or edit them). The problem can be solved by changing to add/remove menu items on installation/uninstallation.

Before

Menu items for the extension were being added using civicrm_navigationMenu hook.

After

Added logic to upgrader to:

Comments

It was not possible to use API to create menu items, as there is a bug currently where if you use the API to create a menu item, and then try to use that menu item as parent of other menu items, the system will throw an exception alerting the parent item is not a valid option, both if using menu item's name or ID. This happens because the list of options (ie. existing navigation menu items) is cached on a class' static attribute the first time the API is called to add a menu item (CRM_Core_PseudoConstant::$cache), so none of the recently added menu items will be available to use as parents.