PHP code example of jtrw / events
1. Go to this page and download the library: Download jtrw/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/ */
jtrw / events example snippets
class PreparedData
{
public const TEST_USER_NAME = "Test User";
public function doPrepareData(\Jtrw\Events\EventSource $eventSource)
{
$target = $eventSource->getTarget();
$target['values']['name'] = static::TEST_USER_NAME;
}
}
$event = new \Jtrw\Events\EventManager();
$event->addListener("testHook", [new PreparedData(), 'doPrepareData']);
$values = [
'name' => 'Hello'
];
$target = [
'values' => &$values
];
$event->fireHook("testHook", $target);
print_r($target);
/*
[values] => Array
(
[name] => Test User
)
*?/