2017 © Pedro Peláez
 

silverstripe-module silverstripe-event-dispatch

Integrate walmsles/event-dispatch into Silverstripe

image

walmsles/silverstripe-event-dispatch

Integrate walmsles/event-dispatch into Silverstripe

  • Friday, November 18, 2016
  • by walmsles
  • Repository
  • 1 Watchers
  • 1 Stars
  • 88 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

silverstripe-event-dispatch

Silverstripe integration of walmsles/event-dispatch PHP module., (*1)

Maintainer Contact

  • Michael Walmsley (michael.walmsley@outlook.com)

Requirements

  • Silverstripe 3.3 (earlier versions probably OK but not tested)

Installation

composer install walmsles/silverstripe-event-dispatch, (*2)

Documentation

A nice decoupled event dispatch model integrated into Silverstripe using a publish/subscribe mechanism., (*3)

Event Module allows registration of listeners to arbitrary events which can be fired anywhere and at anytime. Listeners are any valid callable PHP structure as defined by PHP's call_user_func_array. e.g. Closure, function name, array definining Class instance and method (array($this, 'myMethod')), (*4)

Calling Methods

There are two ways to call functions on the event dispatcher that have identical results - EventDispatcher::dispatch('myEvent', array('event data', 'event data 2')); - EventDispatcher::inst()->dispatch('myEvent', array('event data', 'event data 2'));, (*5)

While the first method is more concise as it uses __callStatic to forward the calls the second method will allow your IDE to autocomplete the available methods. The choice is yours., (*6)

EventDispatcher::inst()->subscribe('myEvent', function($myData1, $myData2) {
    // so somehting with $myData

    return $myData1 . ' ' . $myData2;
});

/** @var array $responses */
$responses = EventDispatcher::inst()->dispatch('myEvent', array('event data', 'event data 2'));

Full documentation is available here, (*7)

The Versions

18/11 2016

dev-master

9999999-dev

Integrate walmsles/event-dispatch into Silverstripe

  Sources   Download

BSD

The Requires

 

The Development Requires

by Michael Walmsley

date time datetime

18/11 2016

1.0.1

1.0.1.0

Integrate walmsles/event-dispatch into Silverstripe

  Sources   Download

BSD

The Requires

 

The Development Requires

by Michael Walmsley

date time datetime

17/11 2016

dev-develop

dev-develop

Integrate walmsles/event-dispatch into Silverstripe

  Sources   Download

BSD

The Requires

 

The Development Requires

by Michael Walmsley

date time datetime

17/11 2016

1.0.0

1.0.0.0

Integrate walmsles/event-dispatch into Silverstripe

  Sources   Download

BSD

The Requires

 

The Development Requires

by Michael Walmsley

date time datetime

08/06 2016

0.1.1

0.1.1.0

Integrate walmsles/event-dispatch into Silverstripe

  Sources   Download

BSD

The Requires

 

The Development Requires

by Michael Walmsley

date time datetime

10/05 2016

0.1.0

0.1.0.0

Integrate walmsles/event-dispatch into Silverstripe

  Sources   Download

BSD

The Requires

 

The Development Requires

by Michael Walmsley

date time datetime