jtrw / events
Events
1.0.2
2021-02-17 15:25 UTC
Requires
- php: >=7.4.1
- symfony/event-dispatcher: ^5.1
Requires (Dev)
- phpunit/phpunit: >=8.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-11-17 23:48:21 UTC
README
Wrapper for symfony Event
Structure Events
- EventManager
- EventSource
Install
Via Composer
$ composer require jtrw/simple-events
Usage EvenManager
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 ) *?/
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test