PHP code example of felicity-php / felicity-events

1. Go to this page and download the library: Download felicity-php/felicity-events library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

felicity-php / felicity-events example snippets




use felicity\events\EventManager;
use felicity\events\models\EventModel;

$demoFunction = function (EventModel $model) {
    // ...do stuff

    // Event may send params on $model->params

    // Pass data back on $model->eventData

    // Stop other listeners on this event from running by
    //      setting $model->stopEventProcessing = true

    // If the sender supports it, tell sender whether it should perform
    //      its action with $model->performAction = false
};

EventManager::on('myEvent', $demoFunction); // Supports any callable



use felicity\events\EventManager;
use felicity\events\models\EventModel;

$eventModel = new EventModel([
    'sender' => $this,
    'params' => [
        'whatever' => 'you want to send',
    ],
]);

EventManager::call('myEvent', $eventModel);