2017 © Pedro Peláez
 

library psr_event

Event Interfaces from Symfony Event Dispatcher Component

image

jakulov/psr_event

Event Interfaces from Symfony Event Dispatcher Component

  • Saturday, January 2, 2016
  • by jakulov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PSR Event

Standarisation of event for compatibility between all component event implement psr-event, (*1)

Use interfaces of https://github.com/symfony/EventDispatcher for create standart full., (*2)

This repository holds all interfaces/classes/traits related to PSR-3., (*3)

Note that this is not a eventDispatcher of its own. It is merely an interface that describes a EventDispatcher, EventSubscriber, EventInterface and GenericEventInterface. See the specification for more details., (*4)

Usage

If you need a eventDispatcher, you can use the interface like this:, (*5)

<?php

use Psr\Log\EventDispatcherInterface;
use Psr\Log\EventInterface;

class Foo
{
    private $logger;

    public function __construct(EventDispatcherInterface $logger = null)
    {
        $this->eventDispatcher = $eventDispatcher;
    }

    public function doSomething()
    {
        if ($this->eventDispatcher) {
            $this->eventDispatcher->addListener('event_name', function (EventInterface $event) {
                // ...
            });

            $this->eventDispatcher->dispatch('event_name');
        }

        // do something useful
    }
}

You can then pick one of the implementations of the interface to get a logger., (*6)

If you want to implement the interface, you can require this package and implement Psr\Log\EventDispatcherInterface in your code. Please read the specification text for details., (*7)

The Versions

02/01 2016

dev-master

9999999-dev

Event Interfaces from Symfony Event Dispatcher Component

  Sources   Download

MIT