forked from PHPDX/cascadiaphp.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceProvider.php
41 lines (35 loc) · 1.02 KB
/
ServiceProvider.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
35
36
37
38
39
40
41
<?php
namespace CascadiaPHP\Site\Router;
use FastRoute\Dispatcher;
use FastRoute\RouteCollector;
use League\Container\ServiceProvider\AbstractServiceProvider;
class ServiceProvider extends AbstractServiceProvider
{
protected $provides = [
Dispatcher::class
];
/**
* Use the register method to register items with the container via the
* protected $this->container property or the `getContainer` method
* from the ContainerAwareTrait.
*
* @return void
*/
public function register()
{
// Set up the router
$this->container->share(Dispatcher::class, function () {
return \FastRoute\simpleDispatcher(function(RouteCollector $routeCollector) {
return $this->routes($routeCollector);
});
});
}
/**
* Load the routes from the bootstrap file
*/
protected function routes(RouteCollector $r)
{
$container = $this->container;
include dirname(__DIR__, 2) . '/bootstrap/routes.php';
}
}