/
Switch to simplified hook definition format

Switch to simplified hook definition format

Right now to create a hook you need to write a code piece, in a unit config, similar to one below:

Current Syntax
array(
	'Mode' => hAFTER,
	'Conditional' => false,
	'HookToPrefix' => 'lang',
	'HookToSpecial' => '*',
	'HookToEvent' => array('OnTargetEvent1', 'OnTargetEvent2', ...),
	'DoPrefix' => '',
	'DoSpecial' => '*',
	'DoEvent' => 'OnHookedEvent',
),

I'm proposing to simplify this syntax by (example, explaining these will follow):

  • setting default values for Mode and Conditional options (that will remove the need to specify these each time), since they're the same for majority of hooks
  • combine HookToPrefix, HookToSpecial and HookToEvent into a single HookTo array
  • combine DoPrefix, DoSpecial and DoEvent into single Do string
Proposed Syntax
array(
	'HookTo' => array('lang.*:OnTargetEvent1', 'lang.*:OnTargetEvent2', ...),
	'Do' => '*:OnHookedEvent',
),

It might be better to actually forbid one-to-many hook definition syntax and force developers to register hooks separately. But that isn't strictly necessary.

The simplified syntax would become even more useful, when More intuitive way to specify event permissions will be implemented (hooks defined in actual event annotations and not a unit config).

Related Tasks