2017 © Pedro Peláez
 

library event

Wrapper for Symfony EventDispatcher component to provide more functionality.

image

atphp/event

Wrapper for Symfony EventDispatcher component to provide more functionality.

  • Monday, January 19, 2015
  • by andytruong
  • Repository
  • 1 Watchers
  • 0 Stars
  • 93 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Event Build Status Latest Stable Version Dependency Status License

Wrapper for Symfony Event Dispatcher to provide more functionality., (*1)

<?php
use Symfony\Component\EventDispatcher\Event;
use AndTruong\Common\EventAware;

class MyClass extends EventAware
{

    public function myEventAwareMethod()
    {
        $this->dispatch('my.event.before');
        $event = new Event();
        $this->dispatch('my.event.after', $event);

        // or simpler
        $this->trigger('my.other.event', $this, ['param 1', 'param 2']);
    }

}

// Class usage
$myobj = new MyClass();
$myobj->getDispatcher()->addListener('my.event.before', function(\AndyTruong\Common\Event $e) {
    $e->getTarget(); // instance of MyClass
    $e->getParams(); // ['param 1', 'param 2']
});
$myobj->myEventAwareMethod();

Result collecting

In real projects, we often collect results from external code. It can be done easily like this:, (*2)

<?php
$myobj = new MyClass();
$myobj->getDispatcher()->addListener('my.results.collecting.event', function(\AndyTruong\Common\Event $e) {
    $e->addResult("Hello there!");
});
$myobj->collectResults('my.results.collecting.event'); // ["Hello there!"]

// to validate input
$myobj->collectResults('my.results.collecting.event', null, null, [
    function($input) {
        if (!is_string($input)) { throw new \Exception('Input must be string!'); }
    }
]); // ["Hello there!"]

The Versions

19/01 2015

0.1.x-dev

0.1.9999999.9999999-dev https://github.com/atphp/event

Wrapper for Symfony EventDispatcher component to provide more functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper event-dispatcher

09/09 2014

v0.1.4

0.1.4.0 https://github.com/andytruong/event

Wrapper for Symfony EventDispatcher component to provide more functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper event-dispatcher

26/08 2014

v0.1.3

0.1.3.0 https://github.com/andytruong/event

Wrapper for Symfony EventDispatcher component to provide more functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper event-dispatcher

15/08 2014

v0.1.2

0.1.2.0 https://github.com/andytruong/event

Wrapper for Symfony EventDispatcher component to provide more functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper event-dispatcher

14/08 2014

v0.1.1

0.1.1.0 https://github.com/andytruong/event

Wrapper for Symfony EventDispatcher component to provide more functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper event-dispatcher

15/07 2014

v0.1.0

0.1.0.0 https://github.com/andytruong/event

Wrapper for Symfony EventDispatcher component to provide more functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper event-dispatcher