@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
| 45 | 45 | { |
| 46 | 46 | $annotation = $this->readAnnotation($controller, $action); |
| 47 | - if ($core instanceof InterceptorPipeline && $annotation->skipNext) { |
|
| 47 | + if ($core instanceof InterceptorPipeline && $annotation->skipNext){ |
|
| 48 | 48 | $this->removeNextInterceptorsFromOriginalPipeline($core); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $pipeline = $this->getCachedPipeline($controller, $action, $annotation); |
| 52 | - if (!empty($pipeline)) { |
|
| 53 | - if ($core instanceof InterceptorPipeline) { |
|
| 52 | + if (!empty($pipeline)){ |
|
| 53 | + if ($core instanceof InterceptorPipeline){ |
|
| 54 | 54 | $this->injectInterceptorsIntoOriginalPipeline($core, $pipeline); |
| 55 | - } else { |
|
| 55 | + }else{ |
|
| 56 | 56 | $core = new InterceptableCore($core); |
| 57 | - foreach ($pipeline as $interceptor) { |
|
| 57 | + foreach ($pipeline as $interceptor){ |
|
| 58 | 58 | $core->addInterceptor($interceptor); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | private function readAnnotation(string $controller, string $action): Pipeline |
| 72 | 72 | { |
| 73 | - try { |
|
| 73 | + try{ |
|
| 74 | 74 | $method = new \ReflectionMethod($controller, $action); |
| 75 | - } catch (\ReflectionException $e) { |
|
| 75 | + }catch (\ReflectionException $e){ |
|
| 76 | 76 | return new Pipeline(); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 93 | 93 | $newInterceptors = []; |
| 94 | - foreach ($oldInterceptors as $interceptor) { |
|
| 94 | + foreach ($oldInterceptors as $interceptor){ |
|
| 95 | 95 | $newInterceptors[] = $interceptor; |
| 96 | - if ($interceptor instanceof self) { |
|
| 96 | + if ($interceptor instanceof self){ |
|
| 97 | 97 | break; |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if (count($newInterceptors) !== count($oldInterceptors)) { |
|
| 101 | + if (count($newInterceptors) !== count($oldInterceptors)){ |
|
| 102 | 102 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 103 | 103 | } |
| 104 | 104 | $pipelineReflection->setAccessible(false); |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 113 | 113 | $newInterceptors = []; |
| 114 | - foreach ($oldInterceptors as $interceptor) { |
|
| 114 | + foreach ($oldInterceptors as $interceptor){ |
|
| 115 | 115 | $newInterceptors[] = $interceptor; |
| 116 | - if ($interceptor instanceof self) { |
|
| 117 | - foreach ($interceptors as $newInterceptor) { |
|
| 116 | + if ($interceptor instanceof self){ |
|
| 117 | + foreach ($interceptors as $newInterceptor){ |
|
| 118 | 118 | $newInterceptors[] = $newInterceptor; |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if (count($newInterceptors) !== count($oldInterceptors)) { |
|
| 123 | + if (count($newInterceptors) !== count($oldInterceptors)){ |
|
| 124 | 124 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 125 | 125 | } |
| 126 | 126 | $pipelineReflection->setAccessible(false); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | private function getCachedPipeline(string $controller, string $action, Pipeline $annotation): array |
| 136 | 136 | { |
| 137 | 137 | $key = "{$controller}:{$action}"; |
| 138 | - if (!array_key_exists($key, $this->cache)) { |
|
| 138 | + if (!array_key_exists($key, $this->cache)){ |
|
| 139 | 139 | $this->cache[$key] = $this->extractAnnotationPipeline($annotation); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | private function extractAnnotationPipeline(Pipeline $annotation): array |
| 150 | 150 | { |
| 151 | 151 | $interceptors = []; |
| 152 | - foreach ($annotation->pipeline as $interceptor) { |
|
| 153 | - try { |
|
| 152 | + foreach ($annotation->pipeline as $interceptor){ |
|
| 153 | + try{ |
|
| 154 | 154 | $interceptors[] = $this->container->get($interceptor); |
| 155 | - } catch (\Throwable $e) { |
|
| 155 | + }catch (\Throwable $e){ |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
@@ -44,17 +44,23 @@ discard block |
||
| 44 | 44 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
| 45 | 45 | { |
| 46 | 46 | $annotation = $this->readAnnotation($controller, $action); |
| 47 | - if ($core instanceof InterceptorPipeline && $annotation->skipNext) { |
|
| 47 | + if ($core instanceof InterceptorPipeline && $annotation->skipNext) |
|
| 48 | + { |
|
| 48 | 49 | $this->removeNextInterceptorsFromOriginalPipeline($core); |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | $pipeline = $this->getCachedPipeline($controller, $action, $annotation); |
| 52 | - if (!empty($pipeline)) { |
|
| 53 | - if ($core instanceof InterceptorPipeline) { |
|
| 53 | + if (!empty($pipeline)) |
|
| 54 | + { |
|
| 55 | + if ($core instanceof InterceptorPipeline) |
|
| 56 | + { |
|
| 54 | 57 | $this->injectInterceptorsIntoOriginalPipeline($core, $pipeline); |
| 55 | - } else { |
|
| 58 | + } |
|
| 59 | + else |
|
| 60 | + { |
|
| 56 | 61 | $core = new InterceptableCore($core); |
| 57 | - foreach ($pipeline as $interceptor) { |
|
| 62 | + foreach ($pipeline as $interceptor) |
|
| 63 | + { |
|
| 58 | 64 | $core->addInterceptor($interceptor); |
| 59 | 65 | } |
| 60 | 66 | } |
@@ -70,9 +76,12 @@ discard block |
||
| 70 | 76 | */ |
| 71 | 77 | private function readAnnotation(string $controller, string $action): Pipeline |
| 72 | 78 | { |
| 73 | - try { |
|
| 79 | + try |
|
| 80 | + { |
|
| 74 | 81 | $method = new \ReflectionMethod($controller, $action); |
| 75 | - } catch (\ReflectionException $e) { |
|
| 82 | + } |
|
| 83 | + catch (\ReflectionException $e) |
|
| 84 | + { |
|
| 76 | 85 | return new Pipeline(); |
| 77 | 86 | } |
| 78 | 87 | |
@@ -91,14 +100,17 @@ discard block |
||
| 91 | 100 | |
| 92 | 101 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 93 | 102 | $newInterceptors = []; |
| 94 | - foreach ($oldInterceptors as $interceptor) { |
|
| 103 | + foreach ($oldInterceptors as $interceptor) |
|
| 104 | + { |
|
| 95 | 105 | $newInterceptors[] = $interceptor; |
| 96 | - if ($interceptor instanceof self) { |
|
| 106 | + if ($interceptor instanceof self) |
|
| 107 | + { |
|
| 97 | 108 | break; |
| 98 | 109 | } |
| 99 | 110 | } |
| 100 | 111 | |
| 101 | - if (count($newInterceptors) !== count($oldInterceptors)) { |
|
| 112 | + if (count($newInterceptors) !== count($oldInterceptors)) |
|
| 113 | + { |
|
| 102 | 114 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 103 | 115 | } |
| 104 | 116 | $pipelineReflection->setAccessible(false); |
@@ -111,16 +123,20 @@ discard block |
||
| 111 | 123 | |
| 112 | 124 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 113 | 125 | $newInterceptors = []; |
| 114 | - foreach ($oldInterceptors as $interceptor) { |
|
| 126 | + foreach ($oldInterceptors as $interceptor) |
|
| 127 | + { |
|
| 115 | 128 | $newInterceptors[] = $interceptor; |
| 116 | - if ($interceptor instanceof self) { |
|
| 117 | - foreach ($interceptors as $newInterceptor) { |
|
| 129 | + if ($interceptor instanceof self) |
|
| 130 | + { |
|
| 131 | + foreach ($interceptors as $newInterceptor) |
|
| 132 | + { |
|
| 118 | 133 | $newInterceptors[] = $newInterceptor; |
| 119 | 134 | } |
| 120 | 135 | } |
| 121 | 136 | } |
| 122 | 137 | |
| 123 | - if (count($newInterceptors) !== count($oldInterceptors)) { |
|
| 138 | + if (count($newInterceptors) !== count($oldInterceptors)) |
|
| 139 | + { |
|
| 124 | 140 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 125 | 141 | } |
| 126 | 142 | $pipelineReflection->setAccessible(false); |
@@ -135,7 +151,8 @@ discard block |
||
| 135 | 151 | private function getCachedPipeline(string $controller, string $action, Pipeline $annotation): array |
| 136 | 152 | { |
| 137 | 153 | $key = "{$controller}:{$action}"; |
| 138 | - if (!array_key_exists($key, $this->cache)) { |
|
| 154 | + if (!array_key_exists($key, $this->cache)) |
|
| 155 | + { |
|
| 139 | 156 | $this->cache[$key] = $this->extractAnnotationPipeline($annotation); |
| 140 | 157 | } |
| 141 | 158 | |
@@ -149,10 +166,14 @@ discard block |
||
| 149 | 166 | private function extractAnnotationPipeline(Pipeline $annotation): array |
| 150 | 167 | { |
| 151 | 168 | $interceptors = []; |
| 152 | - foreach ($annotation->pipeline as $interceptor) { |
|
| 153 | - try { |
|
| 169 | + foreach ($annotation->pipeline as $interceptor) |
|
| 170 | + { |
|
| 171 | + try |
|
| 172 | + { |
|
| 154 | 173 | $interceptors[] = $this->container->get($interceptor); |
| 155 | - } catch (\Throwable $e) { |
|
| 174 | + } |
|
| 175 | + catch (\Throwable $e) |
|
| 176 | + { |
|
| 156 | 177 | } |
| 157 | 178 | } |
| 158 | 179 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): array |
| 20 | 20 | { |
| 21 | 21 | $result = $core->callAction($controller, $action, $parameters); |
| 22 | - if (!is_array($result)) { |
|
| 22 | + if (!is_array($result)){ |
|
| 23 | 23 | $result = []; |
| 24 | 24 | } |
| 25 | 25 | $result[] = $this->string; |
@@ -19,7 +19,8 @@ |
||
| 19 | 19 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): array |
| 20 | 20 | { |
| 21 | 21 | $result = $core->callAction($controller, $action, $parameters); |
| 22 | - if (!is_array($result)) { |
|
| 22 | + if (!is_array($result)) |
|
| 23 | + { |
|
| 23 | 24 | $result = []; |
| 24 | 25 | } |
| 25 | 26 | $result[] = $this->string; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | new Route('/auth/<action>', new Controller(AuthController::class)) |
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | - $views->addDirectory('custom', __DIR__ . '/../../views/custom/'); |
|
| 92 | + $views->addDirectory('custom', __DIR__.'/../../views/custom/'); |
|
| 93 | 93 | $views->addEngine(TestEngine::class); |
| 94 | 94 | |
| 95 | 95 | $validation->addAlias('aliased', 'notEmpty'); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | { |
| 174 | 174 | $core = new InterceptableCore($this->core); |
| 175 | 175 | |
| 176 | - foreach ($interceptors as $interceptor) { |
|
| 176 | + foreach ($interceptors as $interceptor){ |
|
| 177 | 177 | $core->addInterceptor(is_object($interceptor) ? $interceptor : $this->container->get($interceptor)); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -173,7 +173,8 @@ |
||
| 173 | 173 | { |
| 174 | 174 | $core = new InterceptableCore($this->core); |
| 175 | 175 | |
| 176 | - foreach ($interceptors as $interceptor) { |
|
| 176 | + foreach ($interceptors as $interceptor) |
|
| 177 | + { |
|
| 177 | 178 | $core->addInterceptor(is_object($interceptor) ? $interceptor : $this->container->get($interceptor)); |
| 178 | 179 | } |
| 179 | 180 | |