2017 © Pedro Peláez
 

library lazy-event-dispatcher

An event dispatcher that holds any events until flushed.

image

robinvdvleuten/lazy-event-dispatcher

An event dispatcher that holds any events until flushed.

  • Monday, May 8, 2017
  • by robinvdvleuten
  • Repository
  • 1 Watchers
  • 1 Stars
  • 549 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 11 % Grown

The README.md

LazyEventDispatcher

An event dispatcher that holds any events until flushed., (*1)

Latest Stable Version Build Status, (*2)

Use Case

If you want to make use of the kernel.terminate event to do some "heavy" action after the response has already streamed back to the client. Symfony does this already by default but with this listener you'll have support for any custom event classes., (*3)

Installation

The recommended way to install the library is through Composer., (*4)

composer require robinvdvleuten/lazy-event-dispatcher

Install the listener as a service afterwards;, (*5)

services:
    app.lazy_event_dispatcher:
        class: Rvdv\LazyEventDispatcher\LazyEventDispatcher
        arguments:
          - "@event_dispatcher"
        tags:
          - { name: kernel.event_listener, event: kernel.terminate, method: flush }

Then add a custom compiler pass to have a new event listener type;, (*6)

<?php

namespace AppBundle;

use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppBundle extends Bundle
{
    /**
     * {@inheritdoc}
     */
    public function build(ContainerBuilder $container)
    {
        $container->addCompilerPass(
            new RegisterListenersPass('app.lazy_event_dispatcher', 'lazy.event_listener', 'lazy.event_subscriber'),
            PassConfig::TYPE_BEFORE_REMOVING
        );
    }
}

You'll then can register any "lazy" event listeners like this;, (*7)

services:
    app.custom_event_listener:
        class: AppBundle\EventListener\CustomEventListener
        tags:
          - { name: lazy.event_listener, event: custom_event }

License

MIT © Robin van der Vleuten, (*8)

The Versions

08/05 2017

dev-master

9999999-dev https://github.com/robinvdvleuten/php-lazy-event-dispatcher

An event dispatcher that holds any events until flushed.

  Sources   Download

MIT

The Requires

 

The Development Requires

08/05 2017

v1.0.0

1.0.0.0 https://github.com/robinvdvleuten/php-lazy-event-dispatcher

An event dispatcher that holds any events until flushed.

  Sources   Download

MIT

The Requires

 

The Development Requires