@@ -5,9 +5,9 @@ |
||
| 5 | 5 | |
| 6 | 6 | namespace tuyakhov\jsonapi\actions; |
| 7 | 7 | |
| 8 | +use Yii; |
|
| 8 | 9 | use yii\base\Model; |
| 9 | 10 | use yii\db\ActiveRecord; |
| 10 | -use Yii; |
|
| 11 | 11 | use yii\web\ServerErrorHttpException; |
| 12 | 12 | |
| 13 | 13 | class UpdateAction extends Action |
@@ -5,12 +5,11 @@ |
||
| 5 | 5 | |
| 6 | 6 | namespace tuyakhov\jsonapi\actions; |
| 7 | 7 | |
| 8 | -use tuyakhov\jsonapi\ResourceInterface; |
|
| 8 | +use Yii; |
|
| 9 | 9 | use yii\data\ActiveDataProvider; |
| 10 | 10 | use yii\db\BaseActiveRecord; |
| 11 | 11 | use yii\web\BadRequestHttpException; |
| 12 | 12 | use yii\web\NotFoundHttpException; |
| 13 | -use Yii; |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * UpdateRelationshipAction implements the API endpoint for updating relationships. |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | public function parse($rawBody, $contentType) |
| 35 | 35 | { |
| 36 | 36 | $array = parent::parse($rawBody, $contentType); |
| 37 | - $data = ArrayHelper::getValue($array, 'data', []); |
|
| 37 | + $data = ArrayHelper::getValue($array, 'data', []); |
|
| 38 | 38 | if (empty($data)) { |
| 39 | 39 | if ($this->throwException) { |
| 40 | 40 | throw new BadRequestHttpException('The request MUST include a single resource object as primary data.'); |
@@ -185,10 +185,10 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $result = []; |
| 187 | 187 | foreach (['id', 'type'] as $key) { |
| 188 | - $getter = 'get' . ucfirst($key); |
|
| 188 | + $getter = 'get'.ucfirst($key); |
|
| 189 | 189 | $value = $identifier->$getter(); |
| 190 | 190 | if ($value === null || is_array($value) || (is_object($value) && !method_exists($value, '__toString'))) { |
| 191 | - throw new InvalidValueException("The value {$key} of resource object " . get_class($identifier) . ' MUST be a string.'); |
|
| 191 | + throw new InvalidValueException("The value {$key} of resource object ".get_class($identifier).' MUST be a string.'); |
|
| 192 | 192 | } |
| 193 | 193 | if ($key === 'type' && $this->pluralize) { |
| 194 | 194 | $value = Inflector::pluralize($value); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | foreach ($relationship as $model) { |
| 218 | 218 | if ($model instanceof ResourceInterface) { |
| 219 | - $deduplicateKey = $model->getType() . '|' . $model->getId(); |
|
| 219 | + $deduplicateKey = $model->getType().'|'.$model->getId(); |
|
| 220 | 220 | if (!isset($includedObjects[$deduplicateKey])) { |
| 221 | 221 | $includedObjects[$deduplicateKey] = $this->serializeModel($model); |
| 222 | 222 | } |