@@ -40,29 +40,26 @@ discard block |
||
40 | 40 | $reflection = $this->getArtifact('reflection'); |
41 | 41 | |
42 | 42 | $queryModel = 'e'; |
43 | - if(strripos($filter['property'], '.')){ |
|
43 | + if (strripos($filter['property'], '.')) { |
|
44 | 44 | $filtr = explode('.', $filter['property']); |
45 | - if($reflection->hasProperty(Inflector::camelize($filtr[0]))){ |
|
45 | + if ($reflection->hasProperty(Inflector::camelize($filtr[0]))) { |
|
46 | 46 | $property = $reflection->getProperty(Inflector::camelize($filtr[0])); |
47 | - $ann = $this->reader->getPropertyAnnotation($property, OneToOne::class)?: |
|
48 | - $this->reader->getPropertyAnnotation($property, OneToMany::class)?: |
|
49 | - $this->reader->getPropertyAnnotation($property, ManyToMany::class)?: |
|
50 | - $this->reader->getPropertyAnnotation($property, ManyToOne::class)?:null; |
|
51 | - if($ann){ |
|
47 | + $ann = $this->reader->getPropertyAnnotation($property, OneToOne::class) ?: $this->reader->getPropertyAnnotation($property, OneToMany::class) ?: $this->reader->getPropertyAnnotation($property, ManyToMany::class) ?: $this->reader->getPropertyAnnotation($property, ManyToOne::class) ?: null; |
|
48 | + if ($ann) { |
|
52 | 49 | $reflection = new \ReflectionClass($ann->targetEntity); |
53 | - if($reflection->hasProperty(Inflector::camelize($filtr[1]))){ |
|
50 | + if ($reflection->hasProperty(Inflector::camelize($filtr[1]))) { |
|
54 | 51 | $property = $reflection->getProperty(Inflector::camelize($filtr[1])); |
55 | 52 | $filter['property'] = Inflector::camelize($filtr[1]); |
56 | 53 | $queryBuilder->leftJoin(sprintf('e.%s', $filtr[0]), $filtr[0]{0}); |
57 | 54 | $queryModel = Inflector::camelize($filtr[0]{0}); |
58 | 55 | } else { |
59 | - throw new BadRequestHttpException('Related property ' . $filtr[1] . ' not found in related model ' . $filtr[0] . ' in filter field'); |
|
56 | + throw new BadRequestHttpException('Related property '.$filtr[1].' not found in related model '.$filtr[0].' in filter field'); |
|
60 | 57 | } |
61 | - }else{ |
|
62 | - throw new BadRequestHttpException('Property ' . $filtr[0] . ' isn\'t related model in filter field'); |
|
58 | + } else { |
|
59 | + throw new BadRequestHttpException('Property '.$filtr[0].' isn\'t related model in filter field'); |
|
63 | 60 | } |
64 | - } else{ |
|
65 | - throw new BadRequestHttpException('Related property ' . $filtr[0] . ' not found in filter field'); |
|
61 | + } else { |
|
62 | + throw new BadRequestHttpException('Related property '.$filtr[0].' not found in filter field'); |
|
66 | 63 | } |
67 | 64 | } |
68 | 65 | |
@@ -111,12 +108,12 @@ discard block |
||
111 | 108 | sprintf( |
112 | 109 | $queryModel.'.%s BETWEEN :%s_min_value AND :%s_max_value', |
113 | 110 | $filter['property'], |
114 | - $filter['property'].($index+10), |
|
115 | - $filter['property'].($index+11) |
|
111 | + $filter['property'].($index + 10), |
|
112 | + $filter['property'].($index + 11) |
|
116 | 113 | ) |
117 | 114 | ) |
118 | - ->setParameter(sprintf('%s_min_value', $filter['property'].($index+10)), $filter['min']) |
|
119 | - ->setParameter(sprintf('%s_max_value', $filter['property'].($index+11)), $filter['max']); |
|
115 | + ->setParameter(sprintf('%s_min_value', $filter['property'].($index + 10)), $filter['min']) |
|
116 | + ->setParameter(sprintf('%s_max_value', $filter['property'].($index + 11)), $filter['max']); |
|
120 | 117 | ; |
121 | 118 | } |
122 | 119 |