@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | public function render(FilterInterface $filter) |
30 | 30 | { |
31 | - switch ($this->strategy) { |
|
31 | + switch ($this->strategy){ |
|
32 | 32 | case self::STRATEGY_JSON_RESPONSE: |
33 | 33 | return [ |
34 | 34 | 'status' => 400, |
@@ -28,7 +28,8 @@ |
||
28 | 28 | */ |
29 | 29 | public function render(FilterInterface $filter) |
30 | 30 | { |
31 | - switch ($this->strategy) { |
|
31 | + switch ($this->strategy) |
|
32 | + { |
|
32 | 33 | case self::STRATEGY_JSON_RESPONSE: |
33 | 34 | return [ |
34 | 35 | 'status' => 400, |
@@ -57,20 +57,20 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
59 | 59 | { |
60 | - foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) { |
|
61 | - if (isset($parameters[$parameter])) { |
|
60 | + foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){ |
|
61 | + if (isset($parameters[$parameter])){ |
|
62 | 62 | continue; |
63 | 63 | } |
64 | 64 | |
65 | 65 | /** @var FilterInterface $filter */ |
66 | 66 | $filter = $this->container->get($filterClass); |
67 | 67 | |
68 | - if (isset($parameters['@context'])) { |
|
68 | + if (isset($parameters['@context'])){ |
|
69 | 69 | // other interceptors can define the validation contex |
70 | 70 | $filter->setContext($parameters['@context']); |
71 | 71 | } |
72 | 72 | |
73 | - if (!$filter->isValid()) { |
|
73 | + if (!$filter->isValid()){ |
|
74 | 74 | return $this->renderInvalid($filter); |
75 | 75 | } |
76 | 76 | |
@@ -99,28 +99,28 @@ discard block |
||
99 | 99 | private function getDeclaredFilters(string $controller, string $action): array |
100 | 100 | { |
101 | 101 | $key = sprintf('%s:%s', $controller, $action); |
102 | - if (array_key_exists($key, $this->cache)) { |
|
102 | + if (array_key_exists($key, $this->cache)){ |
|
103 | 103 | return $this->cache[$key]; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->cache[$key] = []; |
107 | - try { |
|
107 | + try{ |
|
108 | 108 | $method = new \ReflectionMethod($controller, $action); |
109 | - } catch (\ReflectionException $e) { |
|
109 | + }catch (\ReflectionException $e){ |
|
110 | 110 | return []; |
111 | 111 | } |
112 | 112 | |
113 | - foreach ($method->getParameters() as $parameter) { |
|
113 | + foreach ($method->getParameters() as $parameter){ |
|
114 | 114 | $class = $this->getParameterClass($parameter); |
115 | 115 | |
116 | - if ($class === null) { |
|
116 | + if ($class === null){ |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | |
120 | - if ($class->implementsInterface(FilterInterface::class)) { |
|
120 | + if ($class->implementsInterface(FilterInterface::class)){ |
|
121 | 121 | $this->cache[$key][$parameter->getName()] = $class->getName(); |
122 | 122 | |
123 | - if (null !== ($renderWith = $this->reader->firstClassMetadata($class, RenderWith::class))) { |
|
123 | + if (null !== ($renderWith = $this->reader->firstClassMetadata($class, RenderWith::class))){ |
|
124 | 124 | $this->renderersCache[$class->getName()] = $this->container->get($renderWith->getRenderer()); |
125 | 125 | } |
126 | 126 | } |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | { |
140 | 140 | $type = $parameter->getType(); |
141 | 141 | |
142 | - if (!$type instanceof \ReflectionNamedType) { |
|
142 | + if (!$type instanceof \ReflectionNamedType){ |
|
143 | 143 | return null; |
144 | 144 | } |
145 | 145 | |
146 | - if ($type->isBuiltin()) { |
|
146 | + if ($type->isBuiltin()){ |
|
147 | 147 | return null; |
148 | 148 | } |
149 | 149 |
@@ -57,20 +57,24 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
59 | 59 | { |
60 | - foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) { |
|
61 | - if (isset($parameters[$parameter])) { |
|
60 | + foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) |
|
61 | + { |
|
62 | + if (isset($parameters[$parameter])) |
|
63 | + { |
|
62 | 64 | continue; |
63 | 65 | } |
64 | 66 | |
65 | 67 | /** @var FilterInterface $filter */ |
66 | 68 | $filter = $this->container->get($filterClass); |
67 | 69 | |
68 | - if (isset($parameters['@context'])) { |
|
70 | + if (isset($parameters['@context'])) |
|
71 | + { |
|
69 | 72 | // other interceptors can define the validation contex |
70 | 73 | $filter->setContext($parameters['@context']); |
71 | 74 | } |
72 | 75 | |
73 | - if (!$filter->isValid()) { |
|
76 | + if (!$filter->isValid()) |
|
77 | + { |
|
74 | 78 | return $this->renderInvalid($filter); |
75 | 79 | } |
76 | 80 | |
@@ -99,28 +103,36 @@ discard block |
||
99 | 103 | private function getDeclaredFilters(string $controller, string $action): array |
100 | 104 | { |
101 | 105 | $key = sprintf('%s:%s', $controller, $action); |
102 | - if (array_key_exists($key, $this->cache)) { |
|
106 | + if (array_key_exists($key, $this->cache)) |
|
107 | + { |
|
103 | 108 | return $this->cache[$key]; |
104 | 109 | } |
105 | 110 | |
106 | 111 | $this->cache[$key] = []; |
107 | - try { |
|
112 | + try |
|
113 | + { |
|
108 | 114 | $method = new \ReflectionMethod($controller, $action); |
109 | - } catch (\ReflectionException $e) { |
|
115 | + } |
|
116 | + catch (\ReflectionException $e) |
|
117 | + { |
|
110 | 118 | return []; |
111 | 119 | } |
112 | 120 | |
113 | - foreach ($method->getParameters() as $parameter) { |
|
121 | + foreach ($method->getParameters() as $parameter) |
|
122 | + { |
|
114 | 123 | $class = $this->getParameterClass($parameter); |
115 | 124 | |
116 | - if ($class === null) { |
|
125 | + if ($class === null) |
|
126 | + { |
|
117 | 127 | continue; |
118 | 128 | } |
119 | 129 | |
120 | - if ($class->implementsInterface(FilterInterface::class)) { |
|
130 | + if ($class->implementsInterface(FilterInterface::class)) |
|
131 | + { |
|
121 | 132 | $this->cache[$key][$parameter->getName()] = $class->getName(); |
122 | 133 | |
123 | - if (null !== ($renderWith = $this->reader->firstClassMetadata($class, RenderWith::class))) { |
|
134 | + if (null !== ($renderWith = $this->reader->firstClassMetadata($class, RenderWith::class))) |
|
135 | + { |
|
124 | 136 | $this->renderersCache[$class->getName()] = $this->container->get($renderWith->getRenderer()); |
125 | 137 | } |
126 | 138 | } |
@@ -139,11 +151,13 @@ discard block |
||
139 | 151 | { |
140 | 152 | $type = $parameter->getType(); |
141 | 153 | |
142 | - if (!$type instanceof \ReflectionNamedType) { |
|
154 | + if (!$type instanceof \ReflectionNamedType) |
|
155 | + { |
|
143 | 156 | return null; |
144 | 157 | } |
145 | 158 | |
146 | - if ($type->isBuiltin()) { |
|
159 | + if ($type->isBuiltin()) |
|
160 | + { |
|
147 | 161 | return null; |
148 | 162 | } |
149 | 163 |