1 | <?php |
||
18 | class SymfonyContainerMiddlewareChain implements MiddlewareChain, ContainerAwareInterface |
||
19 | { |
||
20 | use ContainerAwareTrait; |
||
21 | |||
22 | /** |
||
23 | * @var string[] |
||
24 | */ |
||
25 | private $middleware_ids = []; |
||
26 | |||
27 | /** |
||
28 | * @param string $service |
||
29 | */ |
||
30 | 1 | public function registerService($service) |
|
31 | { |
||
32 | 1 | $index = array_search($service, $this->middleware_ids); |
|
33 | |||
34 | // move existing middleware to end of chain |
||
35 | 1 | if ($index !== false) { |
|
36 | 1 | unset($this->middleware_ids[$index]); |
|
37 | // correct array indexes |
||
38 | 1 | $this->middleware_ids = array_values($this->middleware_ids); |
|
39 | 1 | } |
|
40 | |||
41 | 1 | $this->middleware_ids[] = $service; |
|
42 | 1 | } |
|
43 | |||
44 | /** |
||
45 | * @param mixed $message |
||
46 | * |
||
47 | * @return mixed |
||
48 | */ |
||
49 | 3 | public function run($message) |
|
53 | |||
54 | /** |
||
55 | * @param int $index |
||
56 | * |
||
57 | * @return callable |
||
58 | */ |
||
59 | 3 | private function call($index) |
|
73 | |||
74 | /** |
||
75 | * @param $index |
||
76 | * |
||
77 | * @return Middleware |
||
78 | */ |
||
79 | 3 | private function lazyLoad($index) |
|
91 | } |
||
92 |