@@ -44,14 +44,14 @@ 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->cleanOriginalPipeline($core); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $pipeline = $this->getCachedPipeline($controller, $action, $annotation); |
| 52 | - if (!empty($pipeline)) { |
|
| 52 | + if (!empty($pipeline)){ |
|
| 53 | 53 | $core = $core instanceof InterceptorPipeline ? $core : new InterceptableCore($core); |
| 54 | - foreach ($pipeline as $interceptor) { |
|
| 54 | + foreach ($pipeline as $interceptor){ |
|
| 55 | 55 | $core->addInterceptor($interceptor); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | private function readAnnotation(string $controller, string $action): Pipeline |
| 68 | 68 | { |
| 69 | - try { |
|
| 69 | + try{ |
|
| 70 | 70 | $method = new \ReflectionMethod($controller, $action); |
| 71 | - } catch (\ReflectionException $e) { |
|
| 71 | + }catch (\ReflectionException $e){ |
|
| 72 | 72 | return new Pipeline(); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 89 | 89 | $newInterceptors = []; |
| 90 | - foreach ($oldInterceptors as $interceptor) { |
|
| 90 | + foreach ($oldInterceptors as $interceptor){ |
|
| 91 | 91 | $newInterceptors[] = $interceptor; |
| 92 | - if ($interceptor instanceof self) { |
|
| 92 | + if ($interceptor instanceof self){ |
|
| 93 | 93 | break; |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if (count($newInterceptors) !== count($oldInterceptors)) { |
|
| 97 | + if (count($newInterceptors) !== count($oldInterceptors)){ |
|
| 98 | 98 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 99 | 99 | } |
| 100 | 100 | $pipelineReflection->setAccessible(false); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | private function getCachedPipeline(string $controller, string $action, Pipeline $annotation): array |
| 110 | 110 | { |
| 111 | 111 | $key = "{$controller}:{$action}"; |
| 112 | - if (!array_key_exists($key, $this->cache)) { |
|
| 112 | + if (!array_key_exists($key, $this->cache)){ |
|
| 113 | 113 | $this->cache[$key] = $this->extractAnnotationPipeline($annotation); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | private function extractAnnotationPipeline(Pipeline $annotation): array |
| 124 | 124 | { |
| 125 | 125 | $interceptors = []; |
| 126 | - foreach ($annotation->pipeline as $interceptor) { |
|
| 127 | - try { |
|
| 126 | + foreach ($annotation->pipeline as $interceptor){ |
|
| 127 | + try{ |
|
| 128 | 128 | $interceptors[] = $this->container->get($interceptor); |
| 129 | - } catch (\Throwable $e) { |
|
| 129 | + }catch (\Throwable $e){ |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -44,14 +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 | 49 | $this->cleanOriginalPipeline($core); |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | $pipeline = $this->getCachedPipeline($controller, $action, $annotation); |
| 52 | - if (!empty($pipeline)) { |
|
| 53 | + if (!empty($pipeline)) |
|
| 54 | + { |
|
| 53 | 55 | $core = $core instanceof InterceptorPipeline ? $core : new InterceptableCore($core); |
| 54 | - foreach ($pipeline as $interceptor) { |
|
| 56 | + foreach ($pipeline as $interceptor) |
|
| 57 | + { |
|
| 55 | 58 | $core->addInterceptor($interceptor); |
| 56 | 59 | } |
| 57 | 60 | } |
@@ -66,9 +69,12 @@ discard block |
||
| 66 | 69 | */ |
| 67 | 70 | private function readAnnotation(string $controller, string $action): Pipeline |
| 68 | 71 | { |
| 69 | - try { |
|
| 72 | + try |
|
| 73 | + { |
|
| 70 | 74 | $method = new \ReflectionMethod($controller, $action); |
| 71 | - } catch (\ReflectionException $e) { |
|
| 75 | + } |
|
| 76 | + catch (\ReflectionException $e) |
|
| 77 | + { |
|
| 72 | 78 | return new Pipeline(); |
| 73 | 79 | } |
| 74 | 80 | |
@@ -87,14 +93,17 @@ discard block |
||
| 87 | 93 | |
| 88 | 94 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 89 | 95 | $newInterceptors = []; |
| 90 | - foreach ($oldInterceptors as $interceptor) { |
|
| 96 | + foreach ($oldInterceptors as $interceptor) |
|
| 97 | + { |
|
| 91 | 98 | $newInterceptors[] = $interceptor; |
| 92 | - if ($interceptor instanceof self) { |
|
| 99 | + if ($interceptor instanceof self) |
|
| 100 | + { |
|
| 93 | 101 | break; |
| 94 | 102 | } |
| 95 | 103 | } |
| 96 | 104 | |
| 97 | - if (count($newInterceptors) !== count($oldInterceptors)) { |
|
| 105 | + if (count($newInterceptors) !== count($oldInterceptors)) |
|
| 106 | + { |
|
| 98 | 107 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 99 | 108 | } |
| 100 | 109 | $pipelineReflection->setAccessible(false); |
@@ -109,7 +118,8 @@ discard block |
||
| 109 | 118 | private function getCachedPipeline(string $controller, string $action, Pipeline $annotation): array |
| 110 | 119 | { |
| 111 | 120 | $key = "{$controller}:{$action}"; |
| 112 | - if (!array_key_exists($key, $this->cache)) { |
|
| 121 | + if (!array_key_exists($key, $this->cache)) |
|
| 122 | + { |
|
| 113 | 123 | $this->cache[$key] = $this->extractAnnotationPipeline($annotation); |
| 114 | 124 | } |
| 115 | 125 | |
@@ -123,10 +133,14 @@ discard block |
||
| 123 | 133 | private function extractAnnotationPipeline(Pipeline $annotation): array |
| 124 | 134 | { |
| 125 | 135 | $interceptors = []; |
| 126 | - foreach ($annotation->pipeline as $interceptor) { |
|
| 127 | - try { |
|
| 136 | + foreach ($annotation->pipeline as $interceptor) |
|
| 137 | + { |
|
| 138 | + try |
|
| 139 | + { |
|
| 128 | 140 | $interceptors[] = $this->container->get($interceptor); |
| 129 | - } catch (\Throwable $e) { |
|
| 141 | + } |
|
| 142 | + catch (\Throwable $e) |
|
| 143 | + { |
|
| 130 | 144 | } |
| 131 | 145 | } |
| 132 | 146 | |