2017 © Pedro Peláez
 

library event-manager-silex-provider

image

phpextra/event-manager-silex-provider

  • Friday, June 5, 2015
  • by jkobus
  • Repository
  • 1 Watchers
  • 2 Stars
  • 745 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Silex Provider for EventManager

No configuration is needed., (*1)

This provider will replace your EventDispatcher class. Default symfony events were not removed and have higher priority. It means that PHPExtra event is always running after the sf event., (*2)

Below is a reference, to see how events from PHPExtra are mapped onto vanilla sf events. All events are cancellable (propagationStop property in sf event). Unlike in symfony, cancellable events are still sent to all listeners. This behaviour may change in future release of event manager., (*3)

Symfony event mapping

kernel.request
PHPExtra\EventManager\Silex\Event\RequestEvent
Symfony\Component\HttpKernel\Event\GetResponseEvent

kernel.controller
PHPExtra\EventManager\Silex\Event\PreDispatchEvent
Symfony\Component\HttpKernel\Event\FilterControllerEvent

kernel.view
PHPExtra\EventManager\Silex\Event\PostDispatchEvent
Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent

kernel.response
PHPExtra\EventManager\Silex\Event\ResponseEvent
Symfony\Component\HttpKernel\Event\FilterResponseEvent

kernel.finish_request
PHPExtra\EventManager\Silex\Event\PostRequestEvent
Symfony\Component\HttpKernel\Event\FinishRequestEvent

kernel.terminate
PHPExtra\EventManager\Silex\Event\PostResponseEvent
Symfony\Component\HttpKernel\Event\PostResponseEvent

Installation and usage

If you are using logger, it will be automatically injected into the event manager. Every class can now be a listener., (*4)

$app = new Silex\Application(array('debug' => true));
$app->register(new \PHPExtra\EventManager\Silex\EventManagerProvider());

$em = $app['event_manager'];

$em->addListener(new \PHPExtra\EventManager\Listener\AnonymousListener(function(RequestEvent $event){
    echo "Im in RequestEvent (Sf GetResponseEvent)";
}));

$em->addListener(new \PHPExtra\EventManager\Listener\AnonymousListener(function(SilexKernelEvent $event){
    echo "Im in some Symfony KernelEvent !";
}));

$em->addListener($app['my_controller']);

$em->addListener($app['mailer']);

...

Exception handling

Exceptions that will occur during an event are suppressed in production mode. In development, the event manager will break the event loop and re-throw all exceptions., (*5)

$em->setThrowExceptions(false); // suppress exceptions and continue event loop

Contributing

All code contributions must go through a pull request. Fork the project, create a feature branch, and send me a pull request. To ensure a consistent code base, you should make sure the code follows the coding standards. If you would like to help take a look at the list of issues., (*6)

Requirements

See composer.json for a full list of dependencies., (*7)

Authors

Jacek Kobus - kobus.jacek@gmail.com, (*8)

License information

See the file LICENSE.txt for copying permission.

The Versions

05/06 2015

3.0.x-dev

3.0.9999999.9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jacek Kobus

29/10 2014
22/04 2014

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jacek Kobus

15/04 2014

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jacek Kobus