2017 © Pedro PelĂĄez
 

library event-bundle

Event library bundle

image

mleko/event-bundle

Event library bundle

  • Monday, August 28, 2017
  • by mleko
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

narrator/narrator-bundle

Travis CI Scrutinizer Code Quality Code Coverage, (*1)

Installation

Add project dependency using Composer:, (*2)

$ composer require narrator/narrator-bundle

Then register bundle by adding it to app/AppKernel.php file, (*3)

<?php
// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Mleko\Narrator\Bundle\NarratorBundle(),
        );

        // ...
    }

    // ...
}

Configure listeners

NarratorBundle loads listeners from dependency container. To use service as a listener you only need to add tag marking service as listener., (*4)

If you had service, (*5)

<service class="Foo\BarBundle\UserInvitationSender">
    // .. arguments, configuration
</service>
class UserInvitationSender {
    ...
    public function handle(\Foo\BarBundle\UserRegistered $event){
        ...
    }
}

To use it as a listener add tag narrator.listener., (*6)

<service class="Foo\BarBundle\UserInvitationSender">
    // .. arguments, configuration
    <tag name="narrator.listener"/>
</service>

Listener don't have to define parameter type in handle method., (*7)

class UserInvitationSender {
    ...
    public function handle($event){
        ...
    }
}

Event type can be passed as tag attribute event which should be FQCN of event., (*8)

<service class="Foo\BarBundle\UserInvitationSender">
    // .. arguments, configuration
    <tag name="narrator.listener" event="Foo\BarBundle\UserRegistered"/>
</service>

By default event is passed to method handle of registered listener. Method name can be changed using method parameter., (*9)

<service class="Foo\BarBundle\UserInvitationSender">
    // .. arguments, configuration
    <tag name="narrator.listener" event="Foo\BarBundle\UserRegistered" method="handleRegistration"/>
</service>

Using method parameter it is possible to use single service to handle different events., (*10)

<service class="Foo\BarBundle\NotificationSender">
    // .. arguments, configuration
    <tag name="narrator.listener" event="Foo\BarBundle\UserRegistered" method="handleRegistration"/>
    <tag name="narrator.listener" event="Foo\BarBundle\UserLoggedIn" method="handleLogin"/>
</service>

Configure event buses

This bundle comes pre-configured with event bus called "default" aliased to narrator.event_bus. You might want to use more buses or reconfigure "default" bus. You can do this via configuration, (*11)

narrator:
  event_bus:
    default:
      resolver:
        type: instanceof
      public: true
    named: ~

This configuration defines two buses: "default" and "named". These buses will be registered as narrator.event_bus.default and narrator.event_bus.named. narrator.event_bus.default will use InstanceOf resolver, therefore it will support event inheritance; narrator.event_bus.named will use default configuration based on strict event name comparison. By default all buses are registered as private services, it is possible to change that on per-bus basis using public parameter., (*12)

The Versions

28/08 2017

dev-master

9999999-dev

Event library bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel KrĂłl

bundle symfony event mleko narrator

28/08 2017

v0.5.1

0.5.1.0

Event library bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel KrĂłl

bundle symfony event mleko narrator

27/08 2017

v0.5

0.5.0.0

Event library bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel KrĂłl

bundle symfony event mleko narrator

27/11 2016
03/10 2016