-
Notifications
You must be signed in to change notification settings - Fork 28
Events
Two events are currently available. One, 'WordWasCreated' is fired after each instance of LimelightWord is created. The other, 'ParseWasSuccessful', is created after LimelightResults is created.
Events are registered in config.php in the 'listeners' field. Register events using the full namespace.
'listeners' => [
'WordWasCreated' => [
'Namespace\For\Your\Listener',
'Namespace\For\Your\Listener'
],
'ParseWasSuccessful' => [
'Namespace\For\Your\Listener'
]
],
Listeners must implement Limelight\Events\LimelightListener, which requires a handle() method. The handle method receives a payload that varies depending on the event type fired. When 'WordWasCreated' is fired, the payload is the instance of LimelightWord that was just created. When 'ParseWasSuccessful' is fired, the payload is the instance of LimelightResults that was created. Listeners do not need to return anything.
It is worth noting that a single instance of each listener is stored on the event dispatcher and reused throughout Limelight's lifecycle to keep the number of objects created to a minimum.