-
Notifications
You must be signed in to change notification settings - Fork 5
/
events.php
34 lines (27 loc) · 1.23 KB
/
events.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
declare(strict_types=1);
use App\CallableEventDispatcherInterface;
use App\Event;
return static function (CallableEventDispatcherInterface $dispatcher) {
$dispatcher->addListener(
Event\BuildConsoleCommands::class,
function (Event\BuildConsoleCommands $event) use ($dispatcher) {
$event->addAliases([
'example:list-stations' => Plugin\ExamplePlugin\Command\ListStations::class,
]);
}
);
// Tell the view handler to look for templates in this directory too
$dispatcher->addListener(Event\BuildView::class, function(Event\BuildView $event) {
$event->getView()->addFolder('example', __DIR__.'/templates');
});
// Add a new route handled exclusively by the plugin.
$dispatcher->addListener(Event\BuildRoutes::class, function(Event\BuildRoutes $event) {
$app = $event->getApp();
$app->get('/example', \Plugin\ExamplePlugin\Controller\HelloWorld::class)
->setName('example-plugin:index:index')
->add(\App\Middleware\EnableView::class);
});
// You can also add classes that implement the EventSubscriberInterface
$dispatcher->addSubscriber(new \Plugin\ExamplePlugin\EventHandler\AllTheListeners);
};