|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* WebHemi. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 5.6 |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright 2012 - 2016 Gixx-web (http://www.gixx-web.com) |
|
8
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
|
9
|
|
|
* |
|
10
|
|
|
* @link http://www.gixx-web.com |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace WebHemi\Application; |
|
13
|
|
|
|
|
14
|
|
|
use WebHemi\Adapter\DependencyInjection\DependencyInjectionAdapterInterface; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class AbstractApplication. |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class AbstractApplication implements ApplicationInterface |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var DependencyInjectionAdapterInterface */ |
|
22
|
|
|
private $container; |
|
23
|
|
|
/** @var EnvironmentManager */ |
|
24
|
|
|
private $environmentManager; |
|
25
|
|
|
/** @var PipelineManager */ |
|
26
|
|
|
private $pipelineManager; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* ApplicationInterface constructor. |
|
30
|
|
|
* |
|
31
|
|
|
* @param DependencyInjectionAdapterInterface $container |
|
32
|
|
|
* @param EnvironmentManager $environmentManager |
|
33
|
|
|
* @param PipelineManager $pipelineManager |
|
34
|
|
|
*/ |
|
35
|
5 |
|
public function __construct( |
|
36
|
|
|
DependencyInjectionAdapterInterface $container, |
|
37
|
|
|
EnvironmentManager $environmentManager, |
|
38
|
|
|
PipelineManager $pipelineManager |
|
39
|
|
|
) { |
|
40
|
5 |
|
$this->container = $container; |
|
41
|
5 |
|
$this->environmentManager = $environmentManager; |
|
42
|
5 |
|
$this->pipelineManager = $pipelineManager; |
|
43
|
5 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Returns the DI Adapter instance. |
|
47
|
|
|
* |
|
48
|
|
|
* @return DependencyInjectionAdapterInterface |
|
49
|
|
|
*/ |
|
50
|
5 |
|
final public function getContainer() |
|
51
|
|
|
{ |
|
52
|
5 |
|
return $this->container; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Gets the environment manager instance. |
|
57
|
|
|
* |
|
58
|
|
|
* @return EnvironmentManager |
|
59
|
|
|
*/ |
|
60
|
4 |
|
final public function getEnvironmentManager() |
|
61
|
|
|
{ |
|
62
|
4 |
|
return $this->environmentManager; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Gets the pipeline manager instance. |
|
67
|
|
|
* |
|
68
|
|
|
* @return PipelineManager |
|
69
|
|
|
*/ |
|
70
|
4 |
|
final public function getPipelineManager() |
|
71
|
|
|
{ |
|
72
|
4 |
|
return $this->pipelineManager; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Runs the application. This is where the magic happens. |
|
77
|
|
|
* For example for a web application this initializes the Request and Response objects, builds the middleware |
|
78
|
|
|
* pipeline, applies the Routing and the Dispatch. |
|
79
|
|
|
* |
|
80
|
|
|
* @return void |
|
81
|
|
|
*/ |
|
82
|
|
|
abstract public function run(); |
|
83
|
|
|
} |
|
84
|
|
|
|