contributte/event-dispatcher – snadna integrace symfony/event-dispatcher

před 9 měsíci

Felix
Nette Core | 902
+
+3
-

contributte/event-dispatcher

Tento balicek spada do rodiny contributte balicku.

Instalace
composer require contributte/event-dispatcher

Pripadne

composer require contributte/event-dispatcher-extra
Pouziti

Pro detailni pouziti sledujte online dokumentaci.

extensions:
    events: Contributte\EventDispatcher\DI\EventDispatcherExtension

events:
    autoload: true/false
    lazy: true/false
Extra rozsireni

Tento balicek ma svoje extra rozsireni pro Nette, ktere pridava podporu Application, Template/Latte, Security eventu. Typicky kdyz chces treba navesit nejaky kod na Application::$onRequest a dalsi.

use Contributte\EventDispatcher\EventSubscriber;
use Contributte\Events\Extra\Event\Application\RequestEvent;

final class LogRequestSubscriber implements EventSubscriber
{

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

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