1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of the `tvi/monitor-bundle` project. |
||
5 | * |
||
6 | * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE.md |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
11 | |||
12 | namespace Tvi\MonitorBundle\Controller; |
||
13 | |||
14 | use Symfony\Component\HttpFoundation\Request; |
||
15 | |||
16 | /** |
||
0 ignored issues
–
show
|
|||
17 | * @author Vladimir Turnaev <[email protected]> |
||
18 | */ |
||
0 ignored issues
–
show
|
|||
19 | trait TraitCommon |
||
20 | { |
||
21 | 58 | protected function getFilterParam(Request $request, $name) |
|
0 ignored issues
–
show
|
|||
22 | { |
||
23 | 58 | $v = $request->get($name, []); |
|
24 | 58 | if (\is_scalar($v)) { |
|
25 | 28 | $v = $v ? [$v] : []; |
|
26 | } |
||
27 | |||
28 | 58 | return !\is_array($v) ? [$v] : $v; |
|
29 | } |
||
30 | |||
31 | /** |
||
0 ignored issues
–
show
|
|||
32 | * return array [$ids, $checks, $groups, $tags]. |
||
0 ignored issues
–
show
|
|||
33 | */ |
||
0 ignored issues
–
show
|
|||
34 | 58 | protected function getFilterParams(Request $request): array |
|
35 | { |
||
36 | 58 | $ids = $this->getFilterParam($request, 'id'); |
|
37 | 58 | $checks = $this->getFilterParam($request, 'check'); |
|
38 | 58 | $groups = $this->getFilterParam($request, 'group'); |
|
39 | 58 | $tags = $this->getFilterParam($request, 'tag'); |
|
40 | |||
41 | 58 | return [$ids, $checks, $groups, $tags]; |
|
42 | } |
||
43 | } |
||
44 |