Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
JsonApiRequestFormatter.php
Go to the documentation of this file.
1<?php
2
4
7
17
18 public function getDatas(?string $model = null): array {
19 $datas = URequest::getRealInput ();
20 if (\count ( $datas ) > 0) {
21 $datas = \current ( array_keys ( $datas ) );
22 $datas = \json_decode ( $datas, true );
23 $attributes = $datas ['data'] ['attributes'] ?? [ ];
24 if (isset ( $datas ['data'] ['id'] ) && isset($model)) {
25 $key = OrmUtils::getFirstKey ( $model );
26 $attributes [$key] = $datas ['data'] ['id'];
27 }
28 $this->loadRelationshipsDatas ( $datas, $attributes, $model );
29 return $attributes;
30 }
31 return ['data'=>[]];
32 }
33
34 protected function loadRelationshipsDatas($datas, &$attributes,$model) {
35 if (isset ( $datas ['data'] ['relationships'] )) {
36 $relationShips = $datas ['data'] ['relationships'];
37 foreach ( $relationShips as $member => $data ) {
38 if (isset ( $data ['data'] ['id'])) {
39 $m = OrmUtils::getJoinColumnName ( $model, $member );
40 $attributes [$m] = $data ['data'] ['id'];
41 }
42 }
43 }
44 }
45}
Ubiquity\controllers\rest\formatters$JsonApiRequestFormatter This class is part of Ubiquity.
Ubiquity\controllers\rest\formatters$RequestFormatter This class is part of Ubiquity.
Object/relational mapping utilities.
Definition OrmUtils.php:17
Http Request utilities, wrapper for accessing to $_GET, $_POST and php://input.
Definition URequest.php:18