|
@@ -1,4 +1,4 @@ discard block |
|
|
block discarded – undo |
|
1
|
|
-<?php declare (strict_types = 1); |
|
|
1
|
+<?php declare(strict_types=1); |
|
2
|
2
|
|
|
3
|
3
|
namespace Limoncello\Flute\Http\Traits; |
|
4
|
4
|
|
|
@@ -110,7 +110,7 @@ discard block |
|
|
block discarded – undo |
|
110
|
110
|
EncoderInterface $encoder |
|
111
|
111
|
): ResponseInterface { |
|
112
|
112
|
$queryParser->parse($index, $queryParams); |
|
113
|
|
- $validatedIndex = (string)$queryParser->getIdentity(); |
|
|
113
|
+ $validatedIndex = (string) $queryParser->getIdentity(); |
|
114
|
114
|
|
|
115
|
115
|
$model = $mapper->applyQueryParameters($queryParser, $crud)->read($validatedIndex); |
|
116
|
116
|
assert(!($model instanceof PaginatedDataInterface)); |
|
@@ -280,7 +280,7 @@ discard block |
|
|
block discarded – undo |
|
280
|
280
|
$title = $formatter->formatMessage(Messages::MSG_ERR_CANNOT_CREATE_NON_UNIQUE_RESOURCE); |
|
281
|
281
|
$details = null; |
|
282
|
282
|
$errorCode = JsonApiResponse::HTTP_CONFLICT; |
|
283
|
|
- $errors->addDataError($title, $details, (string)$errorCode); |
|
|
283
|
+ $errors->addDataError($title, $details, (string) $errorCode); |
|
284
|
284
|
|
|
285
|
285
|
throw new JsonApiException($errors); |
|
286
|
286
|
} |
|
@@ -409,7 +409,7 @@ discard block |
|
|
block discarded – undo |
|
409
|
409
|
list ($index, $attributes, $toMany) = static::mapSchemaDataToModelData($captures, $schemaClass, $schemaInfo); |
|
410
|
410
|
|
|
411
|
411
|
try { |
|
412
|
|
- $updated = $crud->update((string)$index, $attributes, $toMany); |
|
|
412
|
+ $updated = $crud->update((string) $index, $attributes, $toMany); |
|
413
|
413
|
} /** @noinspection PhpRedundantCatchClauseInspection */ catch (UniqueConstraintViolationException $exception) { |
|
414
|
414
|
$errors = $errorFactory->createErrorCollection(); |
|
415
|
415
|
$formatter = $formatterFactory->createFormatter(Messages::NAMESPACE_NAME); |
|
@@ -417,7 +417,7 @@ discard block |
|
|
block discarded – undo |
|
417
|
417
|
->formatMessage(Messages::MSG_ERR_CANNOT_UPDATE_WITH_UNIQUE_CONSTRAINT_VIOLATION); |
|
418
|
418
|
$details = null; |
|
419
|
419
|
$errorCode = JsonApiResponse::HTTP_CONFLICT; |
|
420
|
|
- $errors->addDataError($title, $details, (string)$errorCode); |
|
|
420
|
+ $errors->addDataError($title, $details, (string) $errorCode); |
|
421
|
421
|
|
|
422
|
422
|
throw new JsonApiException($errors); |
|
423
|
423
|
} |
|
@@ -470,7 +470,7 @@ discard block |
|
|
block discarded – undo |
|
470
|
470
|
CrudInterface $crud, |
|
471
|
471
|
EncoderInterface $encoder |
|
472
|
472
|
): ResponseInterface { |
|
473
|
|
- $validatedIndex = (string)$queryParser->parse($index)->getIdentity(); |
|
|
473
|
+ $validatedIndex = (string) $queryParser->parse($index)->getIdentity(); |
|
474
|
474
|
$crud->remove($validatedIndex); |
|
475
|
475
|
|
|
476
|
476
|
$responses = static::defaultCreateResponses($requestUri, $encoder); |
|
@@ -523,7 +523,7 @@ discard block |
|
|
block discarded – undo |
|
523
|
523
|
$captures = $dataValidator->assertRelationship($index, $jsonRelName, $jsonData)->getCaptures(); |
|
524
|
524
|
$relIds = $captures[$jsonRelName]; |
|
525
|
525
|
|
|
526
|
|
- $validatedIndex = (string)$queryParser->parse($index)->getIdentity(); |
|
|
526
|
+ $validatedIndex = (string) $queryParser->parse($index)->getIdentity(); |
|
527
|
527
|
$parentCrud->createInBelongsToManyRelationship($validatedIndex, $modelRelName, $relIds); |
|
528
|
528
|
|
|
529
|
529
|
$responses = static::defaultCreateResponses($requestUri, $encoder); |
|
@@ -576,7 +576,7 @@ discard block |
|
|
block discarded – undo |
|
576
|
576
|
$captures = $dataValidator->assertRelationship($index, $jsonRelName, $jsonData)->getCaptures(); |
|
577
|
577
|
$relIds = $captures[$jsonRelName]; |
|
578
|
578
|
|
|
579
|
|
- $validatedIndex = (string)$queryParser->parse($index)->getIdentity(); |
|
|
579
|
+ $validatedIndex = (string) $queryParser->parse($index)->getIdentity(); |
|
580
|
580
|
$parentCrud->removeInBelongsToManyRelationship($validatedIndex, $modelRelName, $relIds); |
|
581
|
581
|
|
|
582
|
582
|
$responses = static::defaultCreateResponses($requestUri, $encoder); |
|
@@ -624,7 +624,7 @@ discard block |
|
|
block discarded – undo |
|
624
|
624
|
$modelClass = $schemaClass::MODEL; |
|
625
|
625
|
assert($schemaInfo->hasRelationship($modelClass, $modelRelName)); |
|
626
|
626
|
assert( |
|
627
|
|
- ($type =$schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO || |
|
|
627
|
+ ($type = $schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO || |
|
628
|
628
|
$type === RelationshipTypes::BELONGS_TO_MANY |
|
629
|
629
|
); |
|
630
|
630
|
|
|
@@ -633,7 +633,7 @@ discard block |
|
|
block discarded – undo |
|
633
|
633
|
|
|
634
|
634
|
// If we are here then we have something in 'data' section. |
|
635
|
635
|
|
|
636
|
|
- $validatedIndex = (string)$queryParser->parse($index)->getIdentity(); |
|
|
636
|
+ $validatedIndex = (string) $queryParser->parse($index)->getIdentity(); |
|
637
|
637
|
list (, $attributes, $toMany) = static::mapSchemaDataToModelData($captures, $schemaClass, $schemaInfo); |
|
638
|
638
|
|
|
639
|
639
|
$updated = $crud->update($validatedIndex, $attributes, $toMany); |
|
@@ -875,7 +875,7 @@ discard block |
|
|
block discarded – undo |
|
875
|
875
|
): string { |
|
876
|
876
|
$schema = $jsonSchemas->getSchema($model); |
|
877
|
877
|
$selfLink = $schema->getSelfLink($model); |
|
878
|
|
- $urlPrefix = (string)$requestUri->withPath('')->withQuery('')->withFragment(''); |
|
|
878
|
+ $urlPrefix = (string) $requestUri->withPath('')->withQuery('')->withFragment(''); |
|
879
|
879
|
$fullUrl = $selfLink->getStringRepresentation($urlPrefix); |
|
880
|
880
|
|
|
881
|
881
|
return $fullUrl; |
|
@@ -888,7 +888,7 @@ discard block |
|
|
block discarded – undo |
|
888
|
888
|
*/ |
|
889
|
889
|
private static function assertClassValueDefined(?string $value): void |
|
890
|
890
|
{ |
|
891
|
|
- assert(empty($value) === false, 'Value should be defined in `' . static::class . '`.'); |
|
|
891
|
+ assert(empty($value) === false, 'Value should be defined in `'.static::class.'`.'); |
|
892
|
892
|
} |
|
893
|
893
|
|
|
894
|
894
|
/** |
|
@@ -901,7 +901,7 @@ discard block |
|
|
block discarded – undo |
|
901
|
901
|
{ |
|
902
|
902
|
assert( |
|
903
|
903
|
array_key_exists($interface, class_implements($class)) === true, |
|
904
|
|
- "Class `$class` should implement `" . $interface . '` interface.' |
|
|
904
|
+ "Class `$class` should implement `".$interface.'` interface.' |
|
905
|
905
|
); |
|
906
|
906
|
} |
|
907
|
907
|
} |