File Manager

Current Directory: /home/astoriaah/www/templates/yootheme-BK/vendor/yootheme/framework/modules/event
Viewing File: /home/astoriaah/www/templates/yootheme-BK/vendor/yootheme/framework/modules/event/README.md
# Event Manager The [EventManager](src/EventManager.php) allows you to subscribe and listen for events that occur in your application. An event is triggered during a certain phase of the code execution. Any other part of your application can register to one or multiple events and perform actions at that specific time. ## Basics Using the EventManager on your application which uses the [EventTrait](src/EventTrait.php). ```php // triggers an event $app->trigger('someEvent', [$arg1, $arg2, ...]); // add event listener $app->on('someEvent', function () { // listener callback ... }); // remove a event listener for 'someEvent' $app->off('someEvent', $listener); // remove all event listeners for 'someEvent' $app->off('someEvent'); ``` ## Register Listeners in a Module Register a listener in your modules index.php, they will be automatically loaded through the [EventLoader](src/Module/EventLoader.php): ```php [ 'events' => [ // event listener (priority 0) 'someEvent' => function () { // listener callback ... }, // event listener (priority 10) 'earlyEvent' => [function () { // listener callback ... }, 10], // event listener (priority -10) 'lateEvent' => [function () { // listener callback ... }, -10], ] ] ```