You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
882 B
PHP
35 lines
882 B
PHP
<?php
|
|
|
|
namespace Engelsystem\Events;
|
|
|
|
use Engelsystem\Config\Config;
|
|
use Engelsystem\Container\ServiceProvider;
|
|
|
|
class EventsServiceProvider extends ServiceProvider
|
|
{
|
|
public function register()
|
|
{
|
|
$dispatcher = $this->app->make(EventDispatcher::class);
|
|
|
|
$this->app->instance(EventDispatcher::class, $dispatcher);
|
|
$this->app->instance('events.dispatcher', $dispatcher);
|
|
|
|
$this->registerEvents($dispatcher);
|
|
}
|
|
|
|
/**
|
|
* @param EventDispatcher $dispatcher
|
|
*/
|
|
protected function registerEvents(EventDispatcher $dispatcher)
|
|
{
|
|
/** @var Config $config */
|
|
$config = $this->app->get('config');
|
|
|
|
foreach ($config->get('event-handlers', []) as $event => $handlers) {
|
|
foreach ((array)$handlers as $handler) {
|
|
$dispatcher->listen($event, $handler);
|
|
}
|
|
}
|
|
}
|
|
}
|