2017 © Pedro Peláez
 

library events

image

mic2100/events

  • Thursday, May 3, 2018
  • by mic2100
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Events Library

Build Status Coverage Status, (*1)

Instructions

Events

Events can either extend the AbstractEvent class or implement the EventInterface Some simple examples, (*2)

class SampleEventOne extends AbstractEvent
{
    protected $handle = 'sample-event-one';

    public function handle(array $params = null) : bool
    {
        return true;
    }
}
class SampleEventTwo extends AbstractEvent
{
    protected $handle = 'sample-event-two';

    public function handle(array $params = null) : bool
    {
        return true;
    }
}

Dispatching

When you have created some events you can add them to the dispatcher. With this you can trigger events using the handle or using a wildcard to trigger multiple events., (*3)

$dispatcher = new Dispatcher;
$dispatcher->addEvent(new SampleEventOne);
$dispatcher->addEvent(new SampleEventTwo);
$dispatcher->addEvent(new SampleEventTwo, 'custom-handle-one');

$dispatcher->trigger('custom-handle-one'); //triggers one event
$dispatcher->trigger('sample-event*'); //triggers two events

The Versions

03/05 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Development Requires

by Michael Bardsley