@@ 122-133 (lines=12) @@ | ||
119 | /** |
|
120 | * {@inheritDoc} |
|
121 | */ |
|
122 | public function createRecord($typeKey, Rest\RestPayload $payload) //, array $fields = [], array $inclusions = []) |
|
123 | { |
|
124 | $normalized = $this->normalize($payload); |
|
125 | $this->validateCreatePayload($typeKey, $normalized); |
|
126 | ||
127 | $model = $this->getStore()->create($normalized['type']); |
|
128 | $model->apply($normalized['properties']); |
|
129 | $model->save(); |
|
130 | $payload = $this->serialize($model); |
|
131 | return $this->createRestResponse(201, $payload); |
|
132 | } |
|
133 | ||
134 | /** |
|
135 | * {@inheritDoc} |
|
136 | */ |
|
@@ 137-147 (lines=11) @@ | ||
134 | /** |
|
135 | * {@inheritDoc} |
|
136 | */ |
|
137 | public function updateRecord($typeKey, $identifier, Rest\RestPayload $payload) // , array $fields = [], array $inclusions = []) |
|
138 | { |
|
139 | $normalized = $this->normalize($payload); |
|
140 | $this->validateUpdatePayload($typeKey, $identifier, $normalized); |
|
141 | ||
142 | $model = $this->getStore()->find($typeKey, $normalized['id']); |
|
143 | $model->apply($normalized['properties']); |
|
144 | $model->save(); |
|
145 | $payload = $this->serialize($model); |
|
146 | return $this->createRestResponse(200, $payload); |
|
147 | } |
|
148 | ||
149 | /** |
|
150 | * {@inheritDoc} |