Event Options
Event options give you the ability to combine multiple and/or kinda similar events into a single event.
Based on additional UI components, a develop gets the possibility to add extra fields to a "event container" which is basically just a fieldset container who listens/links to the selected event.
Basic idea
In previous versions of MageHook you would have to create a event for both login and logout. Now you can add one single event with an added multiselect field which provides you the option to select if the hook needs to be dispatched both on login and logout, or one of both.
A developer has multiple options, like the "additional" array parameter, to mark the authentication method (login or logout). This method can be reflected within a custom ValidationInterface
who has the power to accept or cancel the final dispatchment.
Milestones
Implement a look a like Sales Rule Conditions configurator
Option to extend existing validator classes (based on a pool) without having to use a before/after plugin
Add new event options field(s)
As a (event) developer, you have the ability to create your own custom event options UI component. These components will be shown within the backend (edit-) form under the "Event Options" tab. The only thing you have to do is adding a UI component XML to view/adminhtml/ui_component. The filename requires a 'magehook_event_options' prefix extended with the event namespace.
You don't have to worry about any save actions. This is been taken care of where only the selected option values for the particular event will be stored as the "custom_options".
Validation
Custom event options will only work if you provide the event with a ValidationInterface
who can be defined within the "validator" element.
Validations can be split up into multiple smaller pieces to get clean and easy to read code. All methods starting with the 'validate' key will be automatically processed on which they always return a boolean. As long as the result is true, the methods will be processed from the top down. All remaining methods will be skipped when one of the methods doesn't return true.
Extend existing Event- Options & Validators
All event options UI components can be extended by default. In order to validate those options, you need to write a before/after plugin on the existing validator class.
Last updated