File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -570,6 +570,32 @@ use Sunrise\Http\Router\Command\RouteListCommand;
570570new RouteListCommand($router);
571571```
572572
573+ ### Events
574+
575+ > Available from version 2.13
576+
577+ ``` bash
578+ composer require symfony/event-dispatcher
579+ ```
580+
581+ ``` php
582+ use Sunrise\Http\Router\Event\RouteEvent;
583+ use Symfony\Component\EventDispatcher\EventDispatcher;
584+
585+ $eventDispatcher = new EventDispatcher();
586+
587+ $eventDispatcher->addListener(RouteEvent::NAME, function (RouteEvent $event) {
588+ // gets the matched route:
589+ $event->getRoute();
590+ // gets the current request:
591+ $event->getRequest();
592+ // overrides the current request:
593+ $event->setRequest(ServerRequestInterface $request);
594+ });
595+
596+ $router->setEventDispatcher($eventDispatcher);
597+ ```
598+
573599---
574600
575601## Test run
You can’t perform that action at this time.
0 commit comments