|
1
|
|
|
<?php |
|
2
|
|
|
namespace keeko\core\kernel; |
|
3
|
|
|
|
|
4
|
|
|
use keeko\core\events\KernelTargetEvent; |
|
5
|
|
|
use keeko\core\package\AbstractApplication; |
|
6
|
|
|
use keeko\core\service\ServiceContainer; |
|
7
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
|
8
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
10
|
|
|
|
|
11
|
|
|
abstract class AbstractKernel { |
|
12
|
|
|
|
|
13
|
|
|
/** @var AbstractApplication */ |
|
14
|
|
|
protected $app; |
|
15
|
|
|
|
|
16
|
|
|
/** @var ServiceContainer */ |
|
17
|
|
|
protected $service; |
|
18
|
|
|
|
|
19
|
|
|
/** @var EventDispatcher */ |
|
20
|
|
|
protected $dispatcher; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct() { |
|
23
|
|
|
$this->service = new ServiceContainer($this); |
|
|
|
|
|
|
24
|
|
|
$this->dispatcher = $this->service->getDispatcher(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Processes the main kernel action |
|
29
|
|
|
* |
|
30
|
|
|
* @return Response |
|
31
|
|
|
*/ |
|
32
|
|
|
abstract public function main(array $options = []); |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Runs a kernel target |
|
36
|
|
|
* |
|
37
|
|
|
* @param RunnableInterface $target |
|
38
|
|
|
* @param Request $request |
|
39
|
|
|
* @return Response |
|
40
|
|
|
*/ |
|
41
|
|
|
public function handle(KernelTargetInterface $target, Request $request) { |
|
42
|
|
|
$event = new KernelTargetEvent($target); |
|
43
|
|
|
|
|
44
|
|
|
$this->dispatcher->dispatch(KernelTargetEvent::BEFORE_RUN, $event); |
|
45
|
|
|
$response = $target->run($request); |
|
46
|
|
|
$this->dispatcher->dispatch(KernelTargetEvent::AFTER_RUN, $event); |
|
47
|
|
|
|
|
48
|
|
|
return $response; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Returns the service container |
|
53
|
|
|
* |
|
54
|
|
|
* @return ServiceContainer |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getServiceContainer() { |
|
57
|
|
|
return $this->service; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Returns the processed application |
|
62
|
|
|
* |
|
63
|
|
|
* @return AbstractApplication |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getApplication() { |
|
66
|
|
|
return $this->app; |
|
67
|
|
|
} |
|
68
|
|
|
} |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.