2017 © Pedro PelĂĄez
 

library events

Basic event dispatcher definition, implement basic Mediator pattern

image

bee4/events

Basic event dispatcher definition, implement basic Mediator pattern

  • Monday, June 6, 2016
  • by shulard
  • Repository
  • 2 Watchers
  • 1 Stars
  • 2,942 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Bee4 / Events v1.1.0

Build Status Scrutinizer Code Quality Code Coverage SensiolabInsight, (*1)

License, (*2)

The main goal of this code is to allow using Event Dispatcher pattern with different popular implementations :, (*3)

This library does not intend to provide the whole possibilities of each adapters but a standard couple of interface which allow to do not depend from one vendor. This way, you can use your preferred event system with one of the bee4/events lib user., (*4)

Installing

Latest Stable Version Total Downloads, (*5)

This project can be installed using Composer. Add the following to your composer.json:, (*6)

{
    "require": {
        "bee4/events": "~1.1"
    }
}

or run this command:, (*7)

composer require bee4/events:~1.1

Event System

DispatcherInterface

Define how an object must trigger an event. It contains 4 methods :, (*8)

  • dispatch to trigger an EventInterface instance
  • on to attach a listener
  • once to attach a listener that will be ran then detached
  • remove to remove a given listener
  • get to retrieve all listeners attached to one event name

DispatcherAwareInterface

Define how an object can rely to a dispatcher to handle events. It contains 4 methods :, (*9)

  • setDispatcher to initialize the current DispatcherInterface
  • getDispatcher to retrieve the current DispatcherInterface
  • hasDispatcher to check if there is a current DispatcherInterface
  • dispatch to dispatch an EventInterface on the link DispatcherInterface if there is one...

EventInterface

Define an event object which can be triggered. There is no default behaviour for this kind of object because an event can be really specific., (*10)

Adapters

I hope you don't want to create your own dispatcher because there are some cool stuff overhere. There are adapters classes located in the Bee4\Events\Adapters namespace :, (*11)

<?php
$vendor = new \Symfony\Component\EventDispatcher\EventDispatcher;
$adapter = new \Bee4\Events\Adapters\SymfonyEventDispatcherAdapter($vendor);

$adapter->on('name', function(EventInterface $event) {
    echo "I have been triggered: ".PHP_EOL.print_r($event, true);
});

//EventImplementation must be defined in your project to suit your needs
//If must implements the `EventInterface` contract
$adapter->dispatch('name', new EventImplementation);

The Versions

06/06 2016

dev-master

9999999-dev

Basic event dispatcher definition, implement basic Mediator pattern

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Stéphane HULARD

06/06 2016

v1.1.0

1.1.0.0

Basic event dispatcher definition, implement basic Mediator pattern

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Stéphane HULARD

19/02 2016

v1.0.3

1.0.3.0

Basic event dispatcher definition, implement basic Mediator pattern

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Stéphane HULARD

29/07 2015

v1.0.2

1.0.2.0

Basic event dispatcher definition, to allow a project to allow to manage events

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Stéphane HULARD

15/06 2015

v1.0.1

1.0.1.0

Basic event dispatcher definition, to allow a project to allow to manage events

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Stéphane HULARD

23/10 2014

v1.0.0

1.0.0.0

Basic event dispatcher definition, to allow a project to allow to manage events

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Stéphane HULARD

06/10 2014

v0.1.1

0.1.1.0

Basic event dispatcher definition, to allow a project to allow to manage events

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Stéphane HULARD

06/10 2014

v0.1.0

0.1.0.0

Basic event dispatcher definition, to allow a project to allow to manage events

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Stéphane HULARD

06/10 2014

v0.0.2

0.0.2.0

Basic event dispatcher definition, to allow a project to allow to manage events

  Sources   Download

Apache-2.0

The Development Requires

by Stéphane HULARD

03/10 2014

v0.0.1

0.0.1.0

Basic event dispatcher definition, to allow a project to allow to manage events

  Sources   Download

Apache-2.0

The Development Requires

by Stéphane HULARD

03/10 2014

v0.0.0

0.0.0.0

Basic event dispatcher definition, to allow a project to allow to manage events

  Sources   Download

Apache-2.0

The Development Requires

by Stéphane HULARD