@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | |
33 | 33 | public function hasOption(string $option): bool |
34 | 34 | { |
35 | - if (!isset($this->mapped[$option])) { |
|
35 | + if (!isset($this->mapped[$option])){ |
|
36 | 36 | return $this->input->hasValue($option); |
37 | 37 | } |
38 | 38 | |
39 | 39 | $mappedOptions = $this->mapped[$option]; |
40 | - foreach ($mappedOptions as $mappedOption) { |
|
40 | + foreach ($mappedOptions as $mappedOption){ |
|
41 | 41 | $paths = $mappedOption[0]; |
42 | 42 | $firstPath = array_shift($paths); |
43 | - if ($this->input->hasValue($firstPath)) { |
|
43 | + if ($this->input->hasValue($firstPath)){ |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | } |
@@ -54,33 +54,33 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function getOption(string $option) |
56 | 56 | { |
57 | - if (!isset($this->mapped[$option])) { |
|
57 | + if (!isset($this->mapped[$option])){ |
|
58 | 58 | return $this->input->getValue($option); |
59 | 59 | } |
60 | 60 | |
61 | 61 | $mappedOptions = $this->mapped[$option]; |
62 | 62 | $output = []; |
63 | - foreach ($mappedOptions as $mappedOption) { |
|
63 | + foreach ($mappedOptions as $mappedOption){ |
|
64 | 64 | [$paths, $to] = $mappedOption; |
65 | 65 | $firstPath = array_shift($paths); |
66 | - if (!$this->input->hasValue($firstPath)) { |
|
66 | + if (!$this->input->hasValue($firstPath)){ |
|
67 | 67 | continue; |
68 | 68 | } |
69 | 69 | |
70 | 70 | $data = $this->input->getValue($firstPath); |
71 | - if (!empty($paths) && !is_array($data)) { |
|
71 | + if (!empty($paths) && !is_array($data)){ |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | - foreach ($paths as $path) { |
|
76 | - if (!is_array($data) || !isset($data[$path])) { |
|
75 | + foreach ($paths as $path){ |
|
76 | + if (!is_array($data) || !isset($data[$path])){ |
|
77 | 77 | continue 2; |
78 | 78 | } |
79 | 79 | $data = $data[$path]; |
80 | 80 | } |
81 | 81 | |
82 | 82 | $result = $data; |
83 | - foreach ($to as $path) { |
|
83 | + foreach ($to as $path){ |
|
84 | 84 | $result = [$path => $result]; |
85 | 85 | } |
86 | 86 | |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | |
93 | 93 | protected function map(): void |
94 | 94 | { |
95 | - foreach ($this->mapping as $from => $to) { |
|
95 | + foreach ($this->mapping as $from => $to){ |
|
96 | 96 | $to = explode('.', $to); |
97 | 97 | $option = array_shift($to); |
98 | - if (!isset($this->mapped[$option])) { |
|
98 | + if (!isset($this->mapped[$option])){ |
|
99 | 99 | $this->mapped[$option] = []; |
100 | 100 | } |
101 | 101 | $this->mapped[$option][] = [explode('.', $from), array_reverse($to)]; |
@@ -32,15 +32,18 @@ discard block |
||
32 | 32 | |
33 | 33 | public function hasOption(string $option): bool |
34 | 34 | { |
35 | - if (!isset($this->mapped[$option])) { |
|
35 | + if (!isset($this->mapped[$option])) |
|
36 | + { |
|
36 | 37 | return $this->input->hasValue($option); |
37 | 38 | } |
38 | 39 | |
39 | 40 | $mappedOptions = $this->mapped[$option]; |
40 | - foreach ($mappedOptions as $mappedOption) { |
|
41 | + foreach ($mappedOptions as $mappedOption) |
|
42 | + { |
|
41 | 43 | $paths = $mappedOption[0]; |
42 | 44 | $firstPath = array_shift($paths); |
43 | - if ($this->input->hasValue($firstPath)) { |
|
45 | + if ($this->input->hasValue($firstPath)) |
|
46 | + { |
|
44 | 47 | return true; |
45 | 48 | } |
46 | 49 | } |
@@ -54,33 +57,40 @@ discard block |
||
54 | 57 | */ |
55 | 58 | public function getOption(string $option) |
56 | 59 | { |
57 | - if (!isset($this->mapped[$option])) { |
|
60 | + if (!isset($this->mapped[$option])) |
|
61 | + { |
|
58 | 62 | return $this->input->getValue($option); |
59 | 63 | } |
60 | 64 | |
61 | 65 | $mappedOptions = $this->mapped[$option]; |
62 | 66 | $output = []; |
63 | - foreach ($mappedOptions as $mappedOption) { |
|
67 | + foreach ($mappedOptions as $mappedOption) |
|
68 | + { |
|
64 | 69 | [$paths, $to] = $mappedOption; |
65 | 70 | $firstPath = array_shift($paths); |
66 | - if (!$this->input->hasValue($firstPath)) { |
|
71 | + if (!$this->input->hasValue($firstPath)) |
|
72 | + { |
|
67 | 73 | continue; |
68 | 74 | } |
69 | 75 | |
70 | 76 | $data = $this->input->getValue($firstPath); |
71 | - if (!empty($paths) && !is_array($data)) { |
|
77 | + if (!empty($paths) && !is_array($data)) |
|
78 | + { |
|
72 | 79 | continue; |
73 | 80 | } |
74 | 81 | |
75 | - foreach ($paths as $path) { |
|
76 | - if (!is_array($data) || !isset($data[$path])) { |
|
82 | + foreach ($paths as $path) |
|
83 | + { |
|
84 | + if (!is_array($data) || !isset($data[$path])) |
|
85 | + { |
|
77 | 86 | continue 2; |
78 | 87 | } |
79 | 88 | $data = $data[$path]; |
80 | 89 | } |
81 | 90 | |
82 | 91 | $result = $data; |
83 | - foreach ($to as $path) { |
|
92 | + foreach ($to as $path) |
|
93 | + { |
|
84 | 94 | $result = [$path => $result]; |
85 | 95 | } |
86 | 96 | |
@@ -92,10 +102,12 @@ discard block |
||
92 | 102 | |
93 | 103 | protected function map(): void |
94 | 104 | { |
95 | - foreach ($this->mapping as $from => $to) { |
|
105 | + foreach ($this->mapping as $from => $to) |
|
106 | + { |
|
96 | 107 | $to = explode('.', $to); |
97 | 108 | $option = array_shift($to); |
98 | - if (!isset($this->mapped[$option])) { |
|
109 | + if (!isset($this->mapped[$option])) |
|
110 | + { |
|
99 | 111 | $this->mapped[$option] = []; |
100 | 112 | } |
101 | 113 | $this->mapped[$option][] = [explode('.', $from), array_reverse($to)]; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $mapper->getOption('sort') |
80 | 80 | ); |
81 | 81 | $this->assertSame( |
82 | - ['byOldestFilter' => false,], |
|
82 | + ['byOldestFilter' => false, ], |
|
83 | 83 | $mapper->getOption('filter') |
84 | 84 | ); |
85 | 85 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $mapper->getOption('sort') |
119 | 119 | ); |
120 | 120 | $this->assertSame( |
121 | - ['by' => ['oldest' => false],], |
|
121 | + ['by' => ['oldest' => false], ], |
|
122 | 122 | $mapper->getOption('filter') |
123 | 123 | ); |
124 | 124 | } |
@@ -116,7 +116,8 @@ discard block |
||
116 | 116 | ['view' => $view, 'source' => $source] = $this->applySorters($view, $source, $schema); |
117 | 117 | ['view' => $view, 'source' => $source] = $this->applyPaginator($view, $source, $schema); |
118 | 118 | |
119 | - if (!is_iterable($source)) { |
|
119 | + if (!is_iterable($source)) |
|
120 | + { |
|
120 | 121 | throw new GridViewException('GridView expects the source to be iterable after all.'); |
121 | 122 | } |
122 | 123 | |
@@ -134,11 +135,14 @@ discard block |
||
134 | 135 | protected function getFilters($source, GridSchema $schema): array |
135 | 136 | { |
136 | 137 | $filters = []; |
137 | - foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) { |
|
138 | - if ($schema->hasFilter($name)) { |
|
138 | + foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) |
|
139 | + { |
|
140 | + if ($schema->hasFilter($name)) |
|
141 | + { |
|
139 | 142 | $filter = $schema->getFilter($name)->withValue($value); |
140 | 143 | |
141 | - if ($filter !== null) { |
|
144 | + if ($filter !== null) |
|
145 | + { |
|
142 | 146 | $source = $this->compiler->compile($source, $filter); |
143 | 147 | $filters[$name] = $filter->getValue(); |
144 | 148 | } |
@@ -150,7 +154,8 @@ discard block |
||
150 | 154 | |
151 | 155 | protected function applyCounter(GridInterface $view, $source, GridSchema $schema): array |
152 | 156 | { |
153 | - if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) { |
|
157 | + if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) |
|
158 | + { |
|
154 | 159 | $view = $view->withOption(GridInterface::COUNT, ($this->count)($source)); |
155 | 160 | } |
156 | 161 | |
@@ -168,11 +173,14 @@ discard block |
||
168 | 173 | protected function getSorters($source, GridSchema $schema): array |
169 | 174 | { |
170 | 175 | $sorters = []; |
171 | - foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) { |
|
172 | - if ($schema->hasSorter($name)) { |
|
176 | + foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) |
|
177 | + { |
|
178 | + if ($schema->hasSorter($name)) |
|
179 | + { |
|
173 | 180 | $sorter = $schema->getSorter($name)->withDirection($value); |
174 | 181 | |
175 | - if ($sorter !== null) { |
|
182 | + if ($sorter !== null) |
|
183 | + { |
|
176 | 184 | $source = $this->compiler->compile($source, $sorter); |
177 | 185 | $sorters[$name] = $sorter->getValue(); |
178 | 186 | } |
@@ -184,7 +192,8 @@ discard block |
||
184 | 192 | |
185 | 193 | protected function applyPaginator(GridInterface $view, $source, GridSchema $schema): array |
186 | 194 | { |
187 | - if ($schema->getPaginator() !== null) { |
|
195 | + if ($schema->getPaginator() !== null) |
|
196 | + { |
|
188 | 197 | ['source' => $source, 'paginator' => $paginator] = $this->getPaginator($source, $schema); |
189 | 198 | $view = $view->withOption(GridInterface::PAGINATOR, $paginator); |
190 | 199 | } |
@@ -195,12 +204,14 @@ discard block |
||
195 | 204 | protected function getPaginator($source, GridSchema $schema): array |
196 | 205 | { |
197 | 206 | $paginator = $schema->getPaginator(); |
198 | - if (!$paginator instanceof FilterInterface) { |
|
207 | + if (!$paginator instanceof FilterInterface) |
|
208 | + { |
|
199 | 209 | throw new CompilerException('Paginator can not be null'); |
200 | 210 | } |
201 | 211 | |
202 | 212 | $withValue = $paginator->withValue($this->getOption(static::KEY_PAGINATE)); |
203 | - if ($withValue === null) { |
|
213 | + if ($withValue === null) |
|
214 | + { |
|
204 | 215 | throw new CompilerException('Paginator can not be null'); |
205 | 216 | } |
206 | 217 | |
@@ -219,7 +230,8 @@ discard block |
||
219 | 230 | protected function getOptionArray(string $option): array |
220 | 231 | { |
221 | 232 | $result = $this->getOption($option); |
222 | - if (!is_array($result)) { |
|
233 | + if (!is_array($result)) |
|
234 | + { |
|
223 | 235 | return []; |
224 | 236 | } |
225 | 237 | |
@@ -234,7 +246,8 @@ discard block |
||
234 | 246 | */ |
235 | 247 | protected function getOption(string $option) |
236 | 248 | { |
237 | - if ($this->mapper->hasOption($option)) { |
|
249 | + if ($this->mapper->hasOption($option)) |
|
250 | + { |
|
238 | 251 | return $this->mapper->getOption($option); |
239 | 252 | } |
240 | 253 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | InputInterface $input = null, |
58 | 58 | GridInterface $view = null, |
59 | 59 | InputMapperInterface $mapper = null |
60 | - ) { |
|
60 | + ){ |
|
61 | 61 | $mapper = $mapper ?? new NullMapper(); |
62 | 62 | |
63 | 63 | $this->compiler = $compiler; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | ['view' => $view, 'source' => $source] = $this->applySorters($view, $source, $schema); |
129 | 129 | ['view' => $view, 'source' => $source] = $this->applyPaginator($view, $source, $schema); |
130 | 130 | |
131 | - if (!is_iterable($source)) { |
|
131 | + if (!is_iterable($source)){ |
|
132 | 132 | throw new GridViewException('GridView expects the source to be iterable after all.'); |
133 | 133 | } |
134 | 134 | |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | protected function getFilters($source, GridSchema $schema): array |
147 | 147 | { |
148 | 148 | $filters = []; |
149 | - foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) { |
|
150 | - if ($schema->hasFilter($name)) { |
|
149 | + foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value){ |
|
150 | + if ($schema->hasFilter($name)){ |
|
151 | 151 | $filter = $schema->getFilter($name)->withValue($value); |
152 | 152 | |
153 | - if ($filter !== null) { |
|
153 | + if ($filter !== null){ |
|
154 | 154 | $source = $this->compiler->compile($source, $filter); |
155 | 155 | $filters[$name] = $filter->getValue(); |
156 | 156 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | protected function applyCounter(GridInterface $view, $source, GridSchema $schema): array |
164 | 164 | { |
165 | - if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) { |
|
165 | + if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)){ |
|
166 | 166 | $view = $view->withOption(GridInterface::COUNT, ($this->count)($source)); |
167 | 167 | } |
168 | 168 | |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | protected function getSorters($source, GridSchema $schema): array |
181 | 181 | { |
182 | 182 | $sorters = []; |
183 | - foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) { |
|
184 | - if ($schema->hasSorter($name)) { |
|
183 | + foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value){ |
|
184 | + if ($schema->hasSorter($name)){ |
|
185 | 185 | $sorter = $schema->getSorter($name)->withDirection($value); |
186 | 186 | |
187 | - if ($sorter !== null) { |
|
187 | + if ($sorter !== null){ |
|
188 | 188 | $source = $this->compiler->compile($source, $sorter); |
189 | 189 | $sorters[$name] = $sorter->getValue(); |
190 | 190 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | protected function applyPaginator(GridInterface $view, $source, GridSchema $schema): array |
198 | 198 | { |
199 | - if ($schema->getPaginator() !== null) { |
|
199 | + if ($schema->getPaginator() !== null){ |
|
200 | 200 | ['source' => $source, 'paginator' => $paginator] = $this->getPaginator($source, $schema); |
201 | 201 | $view = $view->withOption(GridInterface::PAGINATOR, $paginator); |
202 | 202 | } |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | protected function getPaginator($source, GridSchema $schema): array |
208 | 208 | { |
209 | 209 | $paginator = $schema->getPaginator(); |
210 | - if (!$paginator instanceof FilterInterface) { |
|
210 | + if (!$paginator instanceof FilterInterface){ |
|
211 | 211 | throw new CompilerException('Paginator can not be null'); |
212 | 212 | } |
213 | 213 | |
214 | 214 | $withValue = $paginator->withValue($this->getOption(static::KEY_PAGINATE)); |
215 | - if ($withValue === null) { |
|
215 | + if ($withValue === null){ |
|
216 | 216 | throw new CompilerException('Paginator can not be null'); |
217 | 217 | } |
218 | 218 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | protected function getOptionArray(string $option): array |
232 | 232 | { |
233 | 233 | $result = $this->getOption($option); |
234 | - if (!is_array($result)) { |
|
234 | + if (!is_array($result)){ |
|
235 | 235 | return []; |
236 | 236 | } |
237 | 237 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | protected function getOption(string $option) |
248 | 248 | { |
249 | - if ($this->mapper->hasOption($option)) { |
|
249 | + if ($this->mapper->hasOption($option)){ |
|
250 | 250 | return $this->mapper->getOption($option); |
251 | 251 | } |
252 | 252 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ContainerInterface $container, |
56 | 56 | FactoryInterface $factory, |
57 | 57 | GridFactory $gridFactory |
58 | - ) { |
|
58 | + ){ |
|
59 | 59 | $this->response = $response; |
60 | 60 | $this->container = $container; |
61 | 61 | $this->factory = $factory; |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | { |
75 | 75 | $result = $core->callAction($controller, $action, $parameters); |
76 | 76 | |
77 | - if (is_iterable($result)) { |
|
77 | + if (is_iterable($result)){ |
|
78 | 78 | $schema = $this->getSchema($controller, $action); |
79 | - if ($schema !== null) { |
|
79 | + if ($schema !== null){ |
|
80 | 80 | $grid = $this->makeFactory($schema) |
81 | 81 | ->withDefaults($schema['defaults']) |
82 | 82 | ->create($result, $schema['grid']); |
83 | 83 | |
84 | - if ($schema['view'] !== null) { |
|
84 | + if ($schema['view'] !== null){ |
|
85 | 85 | $grid = $grid->withView($schema['view']); |
86 | 86 | } |
87 | 87 | |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | private function getSchema(string $controller, string $action): ?array |
102 | 102 | { |
103 | 103 | $key = sprintf('%s:%s', $controller, $action); |
104 | - if (array_key_exists($key, $this->cache)) { |
|
104 | + if (array_key_exists($key, $this->cache)){ |
|
105 | 105 | return $this->cache[$key]; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $this->cache[$key] = null; |
109 | - try { |
|
109 | + try{ |
|
110 | 110 | $method = new \ReflectionMethod($controller, $action); |
111 | - } catch (\ReflectionException $e) { |
|
111 | + }catch (\ReflectionException $e){ |
|
112 | 112 | return null; |
113 | 113 | } |
114 | 114 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | /** @var DataGrid $dataGrid */ |
118 | 118 | $dataGrid = $reader->getMethodAnnotation($method, DataGrid::class); |
119 | - if ($dataGrid === null) { |
|
119 | + if ($dataGrid === null){ |
|
120 | 120 | return null; |
121 | 121 | } |
122 | 122 | |
@@ -139,23 +139,23 @@ discard block |
||
139 | 139 | 'mapping' => $dataGrid->mapping, |
140 | 140 | ]; |
141 | 141 | |
142 | - if (is_string($schema['view'])) { |
|
142 | + if (is_string($schema['view'])){ |
|
143 | 143 | $schema['view'] = $this->container->get($schema['view']); |
144 | 144 | } |
145 | 145 | |
146 | - if ($schema['defaults'] === [] && method_exists($schema['grid'], 'getDefaults')) { |
|
146 | + if ($schema['defaults'] === [] && method_exists($schema['grid'], 'getDefaults')){ |
|
147 | 147 | $schema['defaults'] = $schema['grid']->getDefaults(); |
148 | 148 | } |
149 | 149 | |
150 | - if ($schema['options'] === [] && method_exists($schema['grid'], 'getOptions')) { |
|
150 | + if ($schema['options'] === [] && method_exists($schema['grid'], 'getOptions')){ |
|
151 | 151 | $schema['options'] = $schema['grid']->getOptions(); |
152 | 152 | } |
153 | 153 | |
154 | - if ($schema['view'] === null && is_callable($schema['grid'])) { |
|
154 | + if ($schema['view'] === null && is_callable($schema['grid'])){ |
|
155 | 155 | $schema['view'] = $schema['grid']; |
156 | 156 | } |
157 | 157 | |
158 | - if ($schema['mapping'] === [] && method_exists($schema['grid'], 'getMapping')) { |
|
158 | + if ($schema['mapping'] === [] && method_exists($schema['grid'], 'getMapping')){ |
|
159 | 159 | $schema['mapping'] = $schema['grid']->getMapping(); |
160 | 160 | } |
161 | 161 | |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | |
165 | 165 | private function makeFactory(array $schema): GridFactoryInterface |
166 | 166 | { |
167 | - if (!empty($schema['factory']) && $this->container->has($schema['factory'])) { |
|
167 | + if (!empty($schema['factory']) && $this->container->has($schema['factory'])){ |
|
168 | 168 | $factory = $this->container->get($schema['factory']); |
169 | - if ($factory instanceof GridFactoryInterface) { |
|
169 | + if ($factory instanceof GridFactoryInterface){ |
|
170 | 170 | return $factory; |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | - if (!empty($schema['mapping']) && !empty($schema['mapper']) && $this->container->has($schema['mapper'])) { |
|
174 | + if (!empty($schema['mapping']) && !empty($schema['mapper']) && $this->container->has($schema['mapper'])){ |
|
175 | 175 | $mapper = $this->factory->make($schema['mapper'], ['mapping' => $schema['mapping']]); |
176 | - if ($mapper instanceof InputMapperInterface) { |
|
176 | + if ($mapper instanceof InputMapperInterface){ |
|
177 | 177 | return $this->gridFactory->withMapper($mapper); |
178 | 178 | } |
179 | 179 | } |
@@ -74,14 +74,17 @@ discard block |
||
74 | 74 | { |
75 | 75 | $result = $core->callAction($controller, $action, $parameters); |
76 | 76 | |
77 | - if (is_iterable($result)) { |
|
77 | + if (is_iterable($result)) |
|
78 | + { |
|
78 | 79 | $schema = $this->getSchema($controller, $action); |
79 | - if ($schema !== null) { |
|
80 | + if ($schema !== null) |
|
81 | + { |
|
80 | 82 | $grid = $this->makeFactory($schema) |
81 | 83 | ->withDefaults($schema['defaults']) |
82 | 84 | ->create($result, $schema['grid']); |
83 | 85 | |
84 | - if ($schema['view'] !== null) { |
|
86 | + if ($schema['view'] !== null) |
|
87 | + { |
|
85 | 88 | $grid = $grid->withView($schema['view']); |
86 | 89 | } |
87 | 90 | |
@@ -101,14 +104,18 @@ discard block |
||
101 | 104 | private function getSchema(string $controller, string $action): ?array |
102 | 105 | { |
103 | 106 | $key = sprintf('%s:%s', $controller, $action); |
104 | - if (array_key_exists($key, $this->cache)) { |
|
107 | + if (array_key_exists($key, $this->cache)) |
|
108 | + { |
|
105 | 109 | return $this->cache[$key]; |
106 | 110 | } |
107 | 111 | |
108 | 112 | $this->cache[$key] = null; |
109 | - try { |
|
113 | + try |
|
114 | + { |
|
110 | 115 | $method = new \ReflectionMethod($controller, $action); |
111 | - } catch (\ReflectionException $e) { |
|
116 | + } |
|
117 | + catch (\ReflectionException $e) |
|
118 | + { |
|
112 | 119 | return null; |
113 | 120 | } |
114 | 121 | |
@@ -116,7 +123,8 @@ discard block |
||
116 | 123 | |
117 | 124 | /** @var DataGrid $dataGrid */ |
118 | 125 | $dataGrid = $reader->getMethodAnnotation($method, DataGrid::class); |
119 | - if ($dataGrid === null) { |
|
126 | + if ($dataGrid === null) |
|
127 | + { |
|
120 | 128 | return null; |
121 | 129 | } |
122 | 130 | |
@@ -139,23 +147,28 @@ discard block |
||
139 | 147 | 'mapping' => $dataGrid->mapping, |
140 | 148 | ]; |
141 | 149 | |
142 | - if (is_string($schema['view'])) { |
|
150 | + if (is_string($schema['view'])) |
|
151 | + { |
|
143 | 152 | $schema['view'] = $this->container->get($schema['view']); |
144 | 153 | } |
145 | 154 | |
146 | - if ($schema['defaults'] === [] && method_exists($schema['grid'], 'getDefaults')) { |
|
155 | + if ($schema['defaults'] === [] && method_exists($schema['grid'], 'getDefaults')) |
|
156 | + { |
|
147 | 157 | $schema['defaults'] = $schema['grid']->getDefaults(); |
148 | 158 | } |
149 | 159 | |
150 | - if ($schema['options'] === [] && method_exists($schema['grid'], 'getOptions')) { |
|
160 | + if ($schema['options'] === [] && method_exists($schema['grid'], 'getOptions')) |
|
161 | + { |
|
151 | 162 | $schema['options'] = $schema['grid']->getOptions(); |
152 | 163 | } |
153 | 164 | |
154 | - if ($schema['view'] === null && is_callable($schema['grid'])) { |
|
165 | + if ($schema['view'] === null && is_callable($schema['grid'])) |
|
166 | + { |
|
155 | 167 | $schema['view'] = $schema['grid']; |
156 | 168 | } |
157 | 169 | |
158 | - if ($schema['mapping'] === [] && method_exists($schema['grid'], 'getMapping')) { |
|
170 | + if ($schema['mapping'] === [] && method_exists($schema['grid'], 'getMapping')) |
|
171 | + { |
|
159 | 172 | $schema['mapping'] = $schema['grid']->getMapping(); |
160 | 173 | } |
161 | 174 | |
@@ -164,16 +177,20 @@ discard block |
||
164 | 177 | |
165 | 178 | private function makeFactory(array $schema): GridFactoryInterface |
166 | 179 | { |
167 | - if (!empty($schema['factory']) && $this->container->has($schema['factory'])) { |
|
180 | + if (!empty($schema['factory']) && $this->container->has($schema['factory'])) |
|
181 | + { |
|
168 | 182 | $factory = $this->container->get($schema['factory']); |
169 | - if ($factory instanceof GridFactoryInterface) { |
|
183 | + if ($factory instanceof GridFactoryInterface) |
|
184 | + { |
|
170 | 185 | return $factory; |
171 | 186 | } |
172 | 187 | } |
173 | 188 | |
174 | - if (!empty($schema['mapping']) && !empty($schema['mapper']) && $this->container->has($schema['mapper'])) { |
|
189 | + if (!empty($schema['mapping']) && !empty($schema['mapper']) && $this->container->has($schema['mapper'])) |
|
190 | + { |
|
175 | 191 | $mapper = $this->factory->make($schema['mapper'], ['mapping' => $schema['mapping']]); |
176 | - if ($mapper instanceof InputMapperInterface) { |
|
192 | + if ($mapper instanceof InputMapperInterface) |
|
193 | + { |
|
177 | 194 | return $this->gridFactory->withMapper($mapper); |
178 | 195 | } |
179 | 196 | } |