Skip to main content
Topic: hooks (Read 1810 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

hooks

Borderline bug/standardization, for sure something to do before RC1.

The hooks of the admin pages come usually in pairs: integrate_modify_something and integrate_save_something.
Now, the integrate_modify always pass the $config_vars (almost always, there may be one or two exceptions, but not a big problem).
The integrate_save, instead, not very consistent, roughly half the time the variable is passed, half is not.

So, I'm confused. lol
Bugs creator.
Features destroyer.
Template killer.

Re: hooks

Reply #1

Well for sure the integrate_modify_something need the config_vars so they can add to that array and show it on the form.

Not clear that integrate_save_bingbangboom need the config_array.  Seems like that would mainly be used to check the returned $_POST values and manipulate / validate them as needed.  We could pass the config_array in the _save, I'm just not sure of the usage case (and would we just pass it as the value vs reference).  In a pinch there is the public method (should be in most of those controllers), to return the config_array, although its not the best named method for that purpose.

Re: hooks

Reply #2

Another hook thing,
Code: [Select]
call_integration_hook('integrate_list_' . $listOptions['id'], array($listOptions));
seems like that should be a PBR to be useful, otherwise not sure how to use / modify $listOptions

Re: hooks

Reply #3

nods about integrate_list.

modify/save I'd go for without passing anything just because it's less work. xD
No, seriously, the "save" should really be only for changing the POST, and in any case, the current value is set in $modSettings, so it's globally accessible anyway. The type of value is known (you are adding it).

Dunno, don't see any reason to have it.
Bugs creator.
Features destroyer.
Template killer.

Re: hooks

Reply #4

I fixed the list options hook issue and that has been merged.

The rest should be fixed/standardized here: https://github.com/elkarte/Elkarte/pull/1619 There were a couple of ones where the config vars were copied to save_vars then manipulated and then passed, I remove all of that so take a look, mainly here: https://github.com/Spuds/Elkarte/commit/858e9acff1d4deecc4031e6045865fb711a73f51

Re: hooks

Reply #5

I was wondering why there were a couple with this "copy-to-save", guess is goo.
Bugs creator.
Features destroyer.
Template killer.