1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mado\QueryBundle\Queries\Options; |
4
|
|
|
|
5
|
|
|
class QueryOptionsBuilder |
6
|
|
|
{ |
7
|
|
|
private $entityAlias; |
8
|
|
|
|
9
|
|
|
public function setEntityAlias(string $entityAlias) |
10
|
|
|
{ |
11
|
|
|
$this->entityAlias = $entityAlias; |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public function builderFromRequest(Request $request = null) |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
$this->ensureEntityAliasIsDefined(); |
17
|
|
|
|
18
|
|
|
$requestAttributes = []; |
19
|
|
|
foreach ($request->attributes->all() as $attributeName => $attributeValue) { |
20
|
|
|
$requestAttributes[$attributeName] = $request->attributes->get( |
21
|
|
|
$attributeName, |
22
|
|
|
$attributeValue |
23
|
|
|
); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
$filters = $request->query->get('filtering', []); |
27
|
|
|
$orFilters = $request->query->get('filtering_or', []); |
28
|
|
|
$sorting = $request->query->get('sorting', []); |
29
|
|
|
$printing = $request->query->get('printing', []); |
30
|
|
|
$rel = $request->query->get('rel', ''); |
31
|
|
|
$page = $request->query->get('page', ''); |
32
|
|
|
$select = $request->query->get('select', $this->getEntityAlias()); |
|
|
|
|
33
|
|
|
$filtering = $request->query->get('filtering', ''); |
34
|
|
|
$limit = $request->query->get('limit', ''); |
35
|
|
|
|
36
|
|
|
$filterOrCorrected = []; |
37
|
|
|
|
38
|
|
|
$count = 0; |
39
|
|
|
foreach ($orFilters as $key => $filter) { |
40
|
|
|
if (is_array($filter)) { |
41
|
|
|
foreach ($filter as $keyInternal => $internal) { |
42
|
|
|
$filterOrCorrected[$keyInternal . '|' . $count] = $internal; |
43
|
|
|
$count += 1; |
44
|
|
|
} |
45
|
|
|
} else { |
46
|
|
|
$filterOrCorrected[$key] = $filter; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$requestProperties = [ |
51
|
|
|
'filtering' => $filtering, |
52
|
|
|
'orFiltering' => $filterOrCorrected, |
53
|
|
|
'limit' => $limit, |
54
|
|
|
'page' => $page, |
55
|
|
|
'filters' => $filters, |
56
|
|
|
'orFilters' => $filterOrCorrected, |
57
|
|
|
'sorting' => $sorting, |
58
|
|
|
'rel' => $rel, |
59
|
|
|
'printing' => $printing, |
60
|
|
|
'select' => $select, |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
$options = array_merge( |
64
|
|
|
$requestAttributes, |
65
|
|
|
$requestProperties |
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
return QueryBuilderOptions::fromArray($options); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function ensureEntityAliasIsDefined() |
72
|
|
|
{ |
73
|
|
|
if (!$this->entityAlias) { |
74
|
|
|
throw new \RuntimeException( |
75
|
|
|
'Oops! Entity alias is missing' |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths