Skip to content

Commit

Permalink
feat(app): add event dispatcher provided by league/event
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelAlphonso committed Nov 8, 2022
1 parent 1202ec1 commit 258be3f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"studio-42/elfinder": "2.1.61",
"symfony/translation": "^3.4",
"tedivm/stash": "~0.16",
"vlucas/phpdotenv": "^5.4"
"vlucas/phpdotenv": "^5.4",
"league/event": "^3.0"
},
"require-dev": {
"cache/void-adapter": "^1.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"psr/http-message": "^1.0",
"psr/log": "^1.0",
"slim/slim": "^3.7",
"vlucas/phpdotenv": "^5.4"
"vlucas/phpdotenv": "^5.4",
"league/event": "^3.0"
},
"require-dev": {
"league/flysystem-aws-s3-v3": "^1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@

// From PSR-7
use Charcoal\Factory\GenericResolver;
use phpDocumentor\Reflection\Types\Void_;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\UriInterface;
// From Pimple
use Pimple\ServiceProviderInterface;
use Pimple\Container;
// From Slim
use Slim\Http\Uri;
// From 'league/climate'
// From 'league'
use League\CLImate\CLImate;
use League\Event\EventDispatcher;
// From Mustache
use Mustache_LambdaHelper as LambdaHelper;
use Charcoal\Factory\GenericFactory as Factory;
Expand All @@ -35,7 +38,6 @@
use Charcoal\App\ServiceProvider\ScriptServiceProvider;
use Charcoal\App\ServiceProvider\LoggerServiceProvider;
use Charcoal\App\Template\TemplateInterface;
use Charcoal\App\Template\TemplateBuilder;
use Charcoal\App\Template\WidgetInterface;
use Charcoal\App\Template\WidgetBuilder;
use Charcoal\View\Twig\DebugHelpers as TwigDebugHelpers;
Expand Down Expand Up @@ -85,6 +87,7 @@ public function register(Container $container)
$this->registerRequestControllerServices($container);
$this->registerModuleServices($container);
$this->registerViewServices($container);
$this->registerEventServices($container);
}

/**
Expand Down Expand Up @@ -587,4 +590,18 @@ protected function registerTwigHelpersServices(Container $container): void
);
});
}

/**
* @param Container $container The DI container.
* @return void
*/
protected function registerEventServices(Container $container): void
{
/**
* @return EventDispatcherInterface
*/
$container['event/dispatcher'] = function (): EventDispatcherInterface {
return new EventDispatcher();
};
}
}

0 comments on commit 258be3f

Please sign in to comment.