@@ -27,7 +27,7 @@ |
||
27 | 27 | { |
28 | 28 | $entity = $this->getArtifact('entity'); |
29 | 29 | |
30 | - if(true !== $this->getArtifact('validation')) { |
|
30 | + if (true !== $this->getArtifact('validation')) { |
|
31 | 31 | return new ArtifactCollection(); |
32 | 32 | } |
33 | 33 |
@@ -23,6 +23,6 @@ |
||
23 | 23 | |
24 | 24 | $response = $step->execute($request); |
25 | 25 | $this->assertInstanceOf(ArtifactCollection::class, $response); |
26 | - $this->assertEquals([0 => ['type' => 'eq','property' => 'title','value' => 'test']], $response->get('filters')->getValue()); |
|
26 | + $this->assertEquals([0 => ['type' => 'eq', 'property' => 'title', 'value' => 'test']], $response->get('filters')->getValue()); |
|
27 | 27 | } |
28 | 28 | } |
@@ -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))); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | private function getReturnedParams($route, $anonymousClass, $canAccessClass) |
178 | 178 | { |
179 | 179 | $reflection = $this->getEntityReflection($route->getDefault('_entity')); |
180 | - $availableParams = $reflection->getName() . "\n"; |
|
180 | + $availableParams = $reflection->getName()."\n"; |
|
181 | 181 | |
182 | 182 | foreach ($reflection->getProperties() as $property) { |
183 | 183 | $anonymous = $this->reader->getPropertyAnnotation($property, $anonymousClass); |
@@ -189,10 +189,9 @@ discard block |
||
189 | 189 | $availableAccess = $access ? $access->roles : $availableAccess; |
190 | 190 | $availableAccess = implode(', ', $availableAccess); |
191 | 191 | |
192 | - $availableParams .= Inflector::tableize($property->getName()) . ':'; |
|
193 | - $availableParams .= $relation ? '<a href="#operations-tag-'.$this->getRelatedPropertyModelName($property).'">Related model</a>' : |
|
194 | - ($column ? $column->type : 'Unknown'); |
|
195 | - $availableParams .= ', Access: ' . $availableAccess . "\n"; |
|
192 | + $availableParams .= Inflector::tableize($property->getName()).':'; |
|
193 | + $availableParams .= $relation ? '<a href="#operations-tag-'.$this->getRelatedPropertyModelName($property).'">Related model</a>' : ($column ? $column->type : 'Unknown'); |
|
194 | + $availableParams .= ', Access: '.$availableAccess."\n"; |
|
196 | 195 | } |
197 | 196 | } |
198 | 197 | |
@@ -246,8 +245,7 @@ discard block |
||
246 | 245 | |
247 | 246 | $param['description'] = $relation ? |
248 | 247 | '<a href="#operations-tag-'.$this->getRelatedPropertyModelName($property).'">'. |
249 | - 'Related model description</a><pre>Access: ' . $availableAccess . '</pre>' : |
|
250 | - '<pre>Access: ' . $availableAccess . '</pre>'; |
|
248 | + 'Related model description</a><pre>Access: '.$availableAccess.'</pre>' : '<pre>Access: '.$availableAccess.'</pre>'; |
|
251 | 249 | |
252 | 250 | $availableParams[] = $param; |
253 | 251 | } |
@@ -259,8 +257,8 @@ discard block |
||
259 | 257 | private function getRelatedPropertyModelName($property) |
260 | 258 | { |
261 | 259 | $annotations = $this->reader->getPropertyAnnotations($property); |
262 | - foreach ($annotations as $annotation){ |
|
263 | - if( |
|
260 | + foreach ($annotations as $annotation) { |
|
261 | + if ( |
|
264 | 262 | $annotation instanceof OneToOne || |
265 | 263 | $annotation instanceof OneToMany || |
266 | 264 | $annotation instanceof ManyToOne || |
@@ -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{ |