Passed
Push — master ( 2d893f...5de32f )
by Atanas
02:41
created

KernelsServiceProvider::bootstrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
nc 1
nop 1
dl 0
loc 1
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
/**
3
 * @package   WPEmerge
4
 * @author    Atanas Angelov <[email protected]>
5
 * @copyright 2018 Atanas Angelov
6
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7
 * @link      https://wpemerge.com/
8
 */
9
10
namespace WPEmerge\Kernels;
11
12
use WPEmerge\ServiceProviders\ExtendsConfigTrait;
13
use WPEmerge\ServiceProviders\ServiceProviderInterface;
14
15
/**
16
 * Provide old input dependencies.
17
 *
18
 * @codeCoverageIgnore
19
 */
20
class KernelsServiceProvider implements ServiceProviderInterface {
21
	use ExtendsConfigTrait;
22
23
	/**
24
	 * {@inheritDoc}
25
	 */
26
	public function register( $container ) {
27
		$this->extendConfig( $container, 'middleware', [
28
			'flash' => \WPEmerge\Flash\FlashMiddleware::class,
29
			'oldinput' => \WPEmerge\Input\OldInputMiddleware::class,
30
		] );
31
		$this->extendConfig( $container, 'middleware_groups', [
32
			'global' => [
33
				'flash',
34
				'oldinput',
35
			],
36
37
			'web' => [],
38
			'ajax' => [],
39
			'admin' => [],
40
		] );
41
		$this->extendConfig( $container, 'middleware_priority', [] );
42
43
		$container[ WPEMERGE_WORDPRESS_HTTP_KERNEL_KEY ] = function ( $c ) {
44
			$kernel = new HttpKernel(
45
				$c[ WPEMERGE_APPLICATION_KEY ],
46
				$c[ WPEMERGE_REQUEST_KEY ],
47
				$c[ WPEMERGE_ROUTING_ROUTER_KEY ],
48
				$c[ WPEMERGE_EXCEPTIONS_ERROR_HANDLER_KEY ]
49
			);
50
51
			$kernel->setMiddleware( $c[ WPEMERGE_CONFIG_KEY ]['middleware'] );
52
			$kernel->setMiddlewareGroups( $c[ WPEMERGE_CONFIG_KEY ]['middleware_groups'] );
53
			$kernel->setMiddlewarePriority( $c[ WPEMERGE_CONFIG_KEY ]['middleware_priority'] );
54
55
			return $kernel;
56
		};
57
	}
58
59
	/**
60
	 * {@inheritDoc}
61
	 */
62
	public function bootstrap( $container ) {
63
		// Nothing to bootstrap.
64
	}
65
}
66