Logic Hook Maintainance, SCM, and a PHP script

After posting an early version of this script on gitter.im/suitecrm/Lobby I was encouraged by @pgr to post about it here.

Perhaps it will spark a discussion on the handling of logic hooks, and a more sane method will arise.

Until then, you can find my script here: https://github.com/OffsiteGuru/logichookmanager

In short, this script parses php files that have logic hooks defined, and programmatically adds them to the logic_hook.php files using data from the functions phpdoc comments.

I put this together because keeping track of which hook functions were being used was getting crazy with the amount of code I was working with. It also makes it possible to use a separate git repo to manage both the hook code and where it’s enabled.

The functions I’ve written should be pretty easy to adapt if we want to roll this functionality into SuiteCRM proper.

With this in place, adding a logic hook to an install would be as simple as dropping a php file in the directory, running the script, then a quick repair.

I wonder if the quick repair functions needed could be run by this script… hmmm

5 Likes

@benjamin.long

Interesting. This should be a good combination with the tool called Edit Logic Hooks created by Marnus van Niekerk to create Logic Hooks from the front end https://mjvn.com/index.php/sugarcrm-tools/

Link to download here:
https://mjvn.com/wp-content/uploads/2018/10/editLogicHooks-1.1.0.zip

Interesting - I didn’t know about this :point_up:

About Ben’s proposal:

I really like it. I suggested on Gitter when we first discussed this, that I would make this a process (maybe a Robo task) that can be run in two ways:

  1. From command-line with a Robo command, specifying a path to scan

  2. From inside the Quick Repair and Rebuild, scanning a well-known conventional path. This would not create the Hook definition files. It would load the hooks directly into the in-memory hook array.