@@ -197,8 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | $param['description'] = $relation ? |
199 | 199 | '<a href="#operations-tag-'.$this->getRelatedPropertyModelName($property).'">'. |
200 | - 'Related model description</a><pre>Access: ' . $availableAccess . '</pre>' : |
|
201 | - '<pre>Access: ' . $availableAccess . '</pre>'; |
|
200 | + 'Related model description</a><pre>Access: '.$availableAccess.'</pre>' : '<pre>Access: '.$availableAccess.'</pre>'; |
|
202 | 201 | |
203 | 202 | $availableParams[] = $param; |
204 | 203 | } |
@@ -210,8 +209,8 @@ discard block |
||
210 | 209 | private function getRelatedPropertyModelName($property) |
211 | 210 | { |
212 | 211 | $annotations = $this->reader->getPropertyAnnotations($property); |
213 | - foreach ($annotations as $annotation){ |
|
214 | - if( |
|
212 | + foreach ($annotations as $annotation) { |
|
213 | + if ( |
|
215 | 214 | $annotation instanceof OneToOne || |
216 | 215 | $annotation instanceof OneToMany || |
217 | 216 | $annotation instanceof ManyToOne || |
@@ -216,7 +216,9 @@ |
||
216 | 216 | $annotation instanceof OneToMany || |
217 | 217 | $annotation instanceof ManyToOne || |
218 | 218 | $annotation instanceof ManyToMany |
219 | - ) $targetEntity = $annotation->targetEntity; |
|
219 | + ) { |
|
220 | + $targetEntity = $annotation->targetEntity; |
|
221 | + } |
|
220 | 222 | } |
221 | 223 | |
222 | 224 | return str_replace('_', '-', Inflector::tableize(substr($targetEntity, strripos($targetEntity, '\\') + 1))); |
@@ -50,23 +50,20 @@ |
||
50 | 50 | $reflection = $this->getArtifact('reflection'); |
51 | 51 | $query = 'e.%s'; |
52 | 52 | |
53 | - if(strripos($sort, '.')){ |
|
53 | + if (strripos($sort, '.')) { |
|
54 | 54 | $sort = explode('.', $sort); |
55 | - if($reflection->hasProperty(Inflector::camelize($sort[0]))){ |
|
55 | + if ($reflection->hasProperty(Inflector::camelize($sort[0]))) { |
|
56 | 56 | $property = $reflection->getProperty(Inflector::camelize($sort[0])); |
57 | - $ann = $this->reader->getPropertyAnnotation($property, OneToOne::class)?: |
|
58 | - $this->reader->getPropertyAnnotation($property, OneToMany::class)?: |
|
59 | - $this->reader->getPropertyAnnotation($property, ManyToMany::class)?: |
|
60 | - $this->reader->getPropertyAnnotation($property, ManyToOne::class)?:null; |
|
61 | - if($ann){ |
|
57 | + $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; |
|
58 | + if ($ann) { |
|
62 | 59 | $reflection = new \ReflectionClass($ann->targetEntity); |
63 | - $query = $sort[0] . '.%s'; |
|
60 | + $query = $sort[0].'.%s'; |
|
64 | 61 | $sort = Inflector::camelize(($sort[1])); |
65 | - } else{ |
|
66 | - throw new BadRequestHttpException('Related property ' . Inflector::camelize($sort[0]) . ' isn\'t related model in sort field'); |
|
62 | + } else { |
|
63 | + throw new BadRequestHttpException('Related property '.Inflector::camelize($sort[0]).' isn\'t related model in sort field'); |
|
67 | 64 | } |
68 | - } else{ |
|
69 | - throw new BadRequestHttpException('Related property ' . Inflector::camelize($sort[0]) . ' not found in sort field'); |
|
65 | + } else { |
|
66 | + throw new BadRequestHttpException('Related property '.Inflector::camelize($sort[0]).' not found in sort field'); |
|
70 | 67 | } |
71 | 68 | } |
72 | 69 |
@@ -40,28 +40,25 @@ |
||
40 | 40 | |
41 | 41 | foreach ($filters as $filter) { |
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 | $queryModel = Inflector::camelize($filtr[0]); |
57 | 54 | } else { |
58 | - throw new BadRequestHttpException('Related property ' . $filtr[1] . ' not found in related model ' . $filtr[0] . ' in filter field'); |
|
55 | + throw new BadRequestHttpException('Related property '.$filtr[1].' not found in related model '.$filtr[0].' in filter field'); |
|
59 | 56 | } |
60 | - }else{ |
|
61 | - throw new BadRequestHttpException('Property ' . $filtr[0] . ' isn\'t related model in filter field'); |
|
57 | + } else { |
|
58 | + throw new BadRequestHttpException('Property '.$filtr[0].' isn\'t related model in filter field'); |
|
62 | 59 | } |
63 | - } else{ |
|
64 | - throw new BadRequestHttpException('Related property ' . $filtr[0] . ' not found in filter field'); |
|
60 | + } else { |
|
61 | + throw new BadRequestHttpException('Related property '.$filtr[0].' not found in filter field'); |
|
65 | 62 | } |
66 | 63 | } |
67 | 64 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | } else { |
58 | 58 | throw new BadRequestHttpException('Related property ' . $filtr[1] . ' not found in related model ' . $filtr[0] . ' in filter field'); |
59 | 59 | } |
60 | - }else{ |
|
60 | + } else{ |
|
61 | 61 | throw new BadRequestHttpException('Property ' . $filtr[0] . ' isn\'t related model in filter field'); |
62 | 62 | } |
63 | 63 | } else{ |