# Content

# Setup

First of all, setup an event dispatcher integration (e.g. contributte/event-dispatcher (opens new window))

Install package

composer require contributte/event-dispatcher-extra
1

Register extension

extensions:
	# register all event bridges
	events.extra: Contributte\Events\Extra\DI\EventBridgesExtension

events.extra:
	# optionally disable these bridges
	application: false
	security: false
	latte: false
1
2
3
4
5
6
7
8
9

You can also register bridges one by one.

extensions:
	# register only bridges of your choice
	events.application: Contributte\Events\Extra\DI\EventApplicationBridgeExtension
	events.security: Contributte\Events\Extra\DI\EventSecurityBridgeExtension
	events.latte: Contributte\Events\Extra\DI\EventLatteBridgeExtension
1
2
3
4
5

# Events list

There are several events on which you can listen to.

Nette Application events:

Connected to Nette\Application\Application events

use Contributte\Events\Extra\Event\Application\StartupEvent;
use Contributte\Events\Extra\Event\Application\RequestEvent;
use Contributte\Events\Extra\Event\Application\PresenterEvent;
use Contributte\Events\Extra\Event\Application\ResponseEvent;
use Contributte\Events\Extra\Event\Application\ShutdownEvent;
use Contributte\Events\Extra\Event\Application\ErrorEvent;
1
2
3
4
5
6

Connected to Nette\Application\UI\Presenter events (Nette\Application\IPresenter is not supported)

use Contributte\Events\Extra\Event\Application\PresenterStartupEvent;
use Contributte\Events\Extra\Event\Application\PresenterShutdownEvent;
1
2

Latte events:

Connected to Latte\Engine::$onCompile event

use Contributte\Events\Extra\Event\Latte\LatteBeforeCompileEvent;
1

Connected to Nette\Bridges\ApplicationLatte\TemplateFactory::$onCreate event

use Contributte\Events\Extra\Event\Latte\TemplateCreateEvent;
1

Nette Security events:

Connected to Nette\Security\User $onLoggedIn and $onLoggedOut events

use Contributte\Events\Extra\Event\Security\LoggedInEvent;
use Contributte\Events\Extra\Event\Security\LoggedOutEvent;
1
2

# Subscriber

use Contributte\Events\Extra\Event\Application\RequestEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class LogRequestSubscriber implements EventSubscriberInterface
{

    public static function getSubscribedEvents(): array
    {
        return [RequestEvent::class => 'onLog'];
    }

    public function onLog(RequestEvent $event): void
    {
        // Do magic..
    }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17