2017 © Pedro Peláez
 

library eventdispatcher

Simply and light event dispatcher. Let's build your own system using abdulklarapl's components!

image

abdulklarapl/eventdispatcher

Simply and light event dispatcher. Let's build your own system using abdulklarapl's components!

  • Thursday, July 4, 2013
  • by Abdulklara
  • Repository
  • 1 Watchers
  • 0 Stars
  • 22 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

EventDispatcher

Build Status, (*1)

Install

  • clone via git: git clone git@github.com:abdulklarapl/EventDispatcher.git
  • install via composer, add: "adulklarapl/eventdispatcher": "dev-master" to your composer.json / require section

About

Abdulklarapl's EventDispatcher is a simply and light event dispatcher. Let's build your own system using abdulklarapl's components!, (*2)

Example

First, create your subscriber:, (*3)

<?php

namespace Acme\EventSubscriber;

use Abdulklarapl\Components\EventDispatcher\Subscriber\SubscriberInterface;
use Abdulklarapl\Components\EventDispatcher\Event\Event;


class SampleSubscriber implements SubscriberInterface
{

    public function getSubscribedEvents()
    {
        return array(
            "foo.bar" => 'fooAction'
        );
    }

    /**
     * method that it's called on 'event.foo'
     *
     * @param Event $event
     */
    public function fooAction(Event $event)
    {
        // I just handled the event!
    }
}

Then, create new instance of EventDispatcher:, (*4)

$subscriber = new SampleSubscriber();

$dispatcher = new Dispatcher();
$dispatcher->addSubscriber($subscriber);

$dispatcher->fire('foo.bar');

Stop propagation

If you don't want to event was propagated after your subscribed calls, you can modify the event:, (*5)

public function fooAction(Event $event)
{
    $event->stopPropagation();
}

The Versions

04/07 2013

dev-master

9999999-dev

Simply and light event dispatcher. Let's build your own system using abdulklarapl's components!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Patryk Szlagowski

component dispatcher abdulklarapl event