1 | <?php |
||
24 | class PipelineManager |
||
25 | { |
||
26 | /** @var ConfigInterface */ |
||
27 | private $config; |
||
28 | /** @var array */ |
||
29 | private $priorityList; |
||
30 | /** @var array */ |
||
31 | private $pipelineList; |
||
32 | /** @var array */ |
||
33 | private $keyMiddlewareList; |
||
34 | /** @var int */ |
||
35 | private $index; |
||
36 | |||
37 | /** |
||
38 | * Pipeline constructor. |
||
39 | * |
||
40 | * @param ConfigInterface $pipelineConfig |
||
41 | */ |
||
42 | 10 | public function __construct(ConfigInterface $pipelineConfig) |
|
64 | |||
65 | /** |
||
66 | * Add middleware definitions to the pipeline. |
||
67 | */ |
||
68 | 10 | private function buildPipeline() |
|
80 | |||
81 | /** |
||
82 | * Checks the given class against Middleware Criterias. |
||
83 | * |
||
84 | * @param $middleWareClass |
||
85 | * |
||
86 | * @throws RuntimeException |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | 10 | private function checkMiddleware($middleWareClass) |
|
114 | |||
115 | /** |
||
116 | * Adds a new middleware to the pipeline queue. |
||
117 | * |
||
118 | * @param string $middleWareClass |
||
119 | * @param int $priority |
||
120 | * |
||
121 | * @throws RuntimeException |
||
122 | * |
||
123 | * @return $this |
||
124 | */ |
||
125 | 10 | public function queueMiddleware($middleWareClass, $priority = 50) |
|
149 | |||
150 | /** |
||
151 | * Sorts the pipeline elements according to the priority. |
||
152 | */ |
||
153 | 6 | private function sortPipeline() |
|
162 | |||
163 | /** |
||
164 | * Starts the pipeline. |
||
165 | * |
||
166 | * @return null|string |
||
167 | */ |
||
168 | 6 | public function start() |
|
175 | |||
176 | /** |
||
177 | * Gets next element from the pipeline. |
||
178 | * |
||
179 | * @return null|string |
||
180 | */ |
||
181 | 7 | public function next() |
|
189 | |||
190 | /** |
||
191 | * Gets the full pipeline list. |
||
192 | * |
||
193 | * @return array |
||
194 | */ |
||
195 | 1 | public function getPipelineList() |
|
199 | } |
||
200 |