|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CarbonFramework\Routing; |
|
4
|
|
|
|
|
5
|
|
|
use CarbonFramework\Framework; |
|
6
|
|
|
use CarbonFramework\ServiceProviders\ServiceProviderInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Provide routing dependencies |
|
10
|
|
|
* |
|
11
|
|
|
* @codeCoverageIgnore |
|
12
|
|
|
*/ |
|
13
|
|
|
class RoutingServiceProvider implements ServiceProviderInterface { |
|
14
|
|
|
/** |
|
15
|
|
|
* {@inheritDoc} |
|
16
|
|
|
*/ |
|
17
|
|
|
public function register( $container ) { |
|
18
|
|
|
$container['framework.config'] = array_merge( [ |
|
19
|
|
|
'global_middleware' => [], |
|
20
|
|
|
], $container['framework.config'] ); |
|
21
|
|
|
|
|
22
|
|
|
$container['framework.routing.global_middleware'] = $container['framework.config']['global_middleware']; |
|
23
|
|
|
$container['framework.routing.global_middleware'] = apply_filters( 'carbon_framework_global_middleware', $container['framework.routing.global_middleware'] ); |
|
24
|
|
|
|
|
25
|
|
|
$container['framework.routing.conditions.custom'] = \CarbonFramework\Routing\Conditions\Custom::class; |
|
26
|
|
|
$container['framework.routing.conditions.url'] = \CarbonFramework\Routing\Conditions\Url::class; |
|
27
|
|
|
$container['framework.routing.conditions.multiple'] = \CarbonFramework\Routing\Conditions\Multiple::class; |
|
28
|
|
|
$container['framework.routing.conditions.post_id'] = \CarbonFramework\Routing\Conditions\PostId::class; |
|
29
|
|
|
$container['framework.routing.conditions.post_slug'] = \CarbonFramework\Routing\Conditions\PostSlug::class; |
|
30
|
|
|
$container['framework.routing.conditions.post_template'] = \CarbonFramework\Routing\Conditions\PostTemplate::class; |
|
31
|
|
|
$container['framework.routing.conditions.post_type'] = \CarbonFramework\Routing\Conditions\PostType::class; |
|
32
|
|
|
$container['framework.routing.conditions.query_var'] = \CarbonFramework\Routing\Conditions\QueryVar::class; |
|
33
|
|
|
$container['framework.routing.conditions.has_query_var'] = \CarbonFramework\Routing\Conditions\HasQueryVar::class; |
|
34
|
|
|
|
|
35
|
|
|
$container['framework.routing.router'] = function() { |
|
36
|
|
|
return new \CarbonFramework\Routing\Router(); |
|
37
|
|
|
}; |
|
38
|
|
|
|
|
39
|
|
|
Framework::facade( 'Router', \CarbonFramework\Routing\RouterFacade::class ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritDoc} |
|
44
|
|
|
*/ |
|
45
|
|
|
public function boot( $container ) { |
|
46
|
|
|
\Router::boot(); // facade |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|