1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: namespace Autarky\Events;
12:
13: use Symfony\Component\Console\Application;
14:
15: use Autarky\Container\ContainerInterface;
16: use Autarky\Providers\AbstractProvider;
17:
18: 19: 20: 21:
22: class EventDispatcherProvider extends AbstractProvider
23: {
24: 25: 26:
27: public function register()
28: {
29: $dic = $this->app->getContainer();
30:
31: $dic->share('Autarky\Events\EventDispatcher');
32:
33: $dic->alias('Autarky\Events\EventDispatcher',
34: 'Symfony\Component\EventDispatcher\EventDispatcherInterface');
35:
36: $dic->resolvingAny(function($obj, ContainerInterface $dic) {
37: if ($obj instanceof EventDispatcherAwareInterface) {
38: $obj->setEventDispatcher($dic->resolve('Autarky\Events\EventDispatcher'));
39: }
40: });
41: }
42:
43: 44: 45:
46: public function registerConsole(Application $console)
47: {
48: $eventDispatcher = $this->app->getContainer()
49: ->resolve('Symfony\Component\EventDispatcher\EventDispatcherInterface');
50: $console->setDispatcher($eventDispatcher);
51: }
52: }
53: