2017 © Pedro Peláez
 

library event-interface

An event manager standard based on PSR-14.

image

dhii/event-interface

An event manager standard based on PSR-14.

  • Monday, April 2, 2018
  • by XedinUnknown
  • Repository
  • 3 Watchers
  • 1 Stars
  • 828 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 101 % Grown

The README.md

Dhii - Event Interface

Build Status Code Climate Test Coverage Latest Stable Version Latest Unstable Version, (*1)

Details

The PSR-14 standard provides interfaces used for dispatching events. But what of events themselves? How can a consumer of the dispatcher (i.e. the emitter) interoperate with the handler, if they have no agreement on what an event may look like? This package aims to provide interfaces that could facilitate the interoperability of events that are identified by event name., (*2)

Usage

Basic Features

In essence, an event is but a map of parameters associated with a name., (*3)

make('my_event', ['key' => 'value']);
echo $event->getName(); // 'my_event'
echo $event->getParam('key'); //  'value'

$params = $event->getParams();
var_dump($params); // ['key' => 'value']

$params['hello'] = 'world';
$event->setParams($params);
echo $event->getParam('hello'); // 'world'
?>

With PSR-14

Evemts cam be dispatched using a standards-compliant event dispatcher. This example requires the already included [dhii/event-dispatcher-interface][] package., (*4)

addListener('my_event', function (EventInterface $event) {
    $params = $event->getParams();
    $params['key'] = 'other_value';
    $event->setParams($params);
    $event->stopPropagation();
}, 1);

// Second listener is never run, therefore the value does not change again
$listenerMap->addListener('my_event', function (EventInterface $event) {
    $params = $event->getParams();
    $params['key'] = 'yet another value';
    $event->setParams($params);
}, 2);

$event = $factory->make('my_event', ['key' => 'value']);
$dispatcher->dispatch($event);
echo $event->getParam('key'); // 'other_value'
?>

The Versions

02/04 2018

dev-develop

dev-develop

An event manager standard based on PSR-14.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dhii Team

02/04 2018

v0.2-alpha1

0.2.0.0-alpha1

An event manager standard based on PSR-14.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dhii Team

13/03 2018

v0.1.1-alpha1

0.1.1.0-alpha1

Interfaces for the PSR-14 standard.

  Sources   Download

MIT

The Requires

  • php ^5.3 | ^7.0

 

The Development Requires

by Dhii Team

06/07 2016

dev-master

9999999-dev

A temporary PSR-14 repository.

  Sources   Download

by Miguel Muscat
by Anton Ukhanev

06/07 2016

0.1

0.1.0.0

A temporary PSR-14 repository.

  Sources   Download

by Miguel Muscat
by Anton Ukhanev