Skip to content
Pretty domain events with inheritance
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build
src/PHPExtra/EventManager
tests
.gitignore
.php_cs.dist
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
composer.json
composer.lock
phpunit.xml.dist

README.md

Event Manager

Latest Stable Version Total Downloads License Build Status Scrutinizer Code Quality Code Coverage

How it works ?

Both the event and listener are (marker) interfaces. Events support inheritance.

Examples

class UserLoginEvent implements Event
{
    public $userId;
}

class UserListener implements Listener
{
    /**
     * Acts on UserLoginEvent or it's descendants
     */
    public function onUserLogin(UserLoginEvent $event)
    {
        echo "User listener 1";
    }

    /**
     * Act on any event
     */
    public function onAnyEvent(Event $event)
    {
        echo "User listener 2";
    }
}

$manager = new EventManager();
$manager->add(new UserListener());
$manager->emit(new UserLoginEvent($user));

Result:

> User listener 1
> User listener 2

Installation (Composer)

composer require phpextra/event-manager:5.*

Running tests

composer tests

Running php-cs-fixer

composer fix

Contributing

All code contributions must go through a pull request. Fork the project, create a feature branch, and send me a pull request. To ensure a consistent code base, you should make sure the code follows the coding standards. If you would like to help, take a look at the list of issues.

Authors

Jacek Kobus - kobus.jacek@gmail.com

You can’t perform that action at this time.