|
@@ 343-359 (lines=17) @@
|
| 340 |
|
* |
| 341 |
|
* returns object|null returns the newly created model if sucessful or null if model creation failed. |
| 342 |
|
*/ |
| 343 |
|
public function createResourceforResourceSet( |
| 344 |
|
ResourceSet $resourceSet, |
| 345 |
|
$sourceEntityInstance, |
| 346 |
|
$data |
| 347 |
|
) { |
| 348 |
|
$verb = 'create'; |
| 349 |
|
$class = $resourceSet->getResourceType()->getInstanceType()->name; |
| 350 |
|
|
| 351 |
|
$data = $this->createUpdateDeleteCore($sourceEntityInstance, $data, $class, $verb); |
| 352 |
|
|
| 353 |
|
$success = isset($data['id']); |
| 354 |
|
|
| 355 |
|
if ($success) { |
| 356 |
|
return $class::findOrFail($data['id']); |
| 357 |
|
} |
| 358 |
|
throw new ODataException('Target model not successfully created', 422); |
| 359 |
|
} |
| 360 |
|
|
| 361 |
|
/** |
| 362 |
|
* @param $sourceEntityInstance |
|
@@ 292-310 (lines=19) @@
|
| 289 |
|
* |
| 290 |
|
* @return object|null The new resource value if it is assignable or throw exception for null. |
| 291 |
|
*/ |
| 292 |
|
public function updateResource( |
| 293 |
|
ResourceSet $sourceResourceSet, |
| 294 |
|
$sourceEntityInstance, |
| 295 |
|
KeyDescriptor $keyDescriptor, |
| 296 |
|
$data, |
| 297 |
|
$shouldUpdate = false |
| 298 |
|
) { |
| 299 |
|
$verb = 'update'; |
| 300 |
|
$class = $sourceResourceSet->getResourceType()->getInstanceType()->name; |
| 301 |
|
|
| 302 |
|
$data = $this->createUpdateDeleteCore($sourceEntityInstance, $data, $class, $verb); |
| 303 |
|
|
| 304 |
|
$success = isset($data['id']); |
| 305 |
|
|
| 306 |
|
if ($success) { |
| 307 |
|
return $class::findOrFail($data['id']); |
| 308 |
|
} |
| 309 |
|
throw new ODataException('Target model not successfully updated', 422); |
| 310 |
|
} |
| 311 |
|
/** |
| 312 |
|
* Delete resource from a resource set. |
| 313 |
|
* @param ResourceSet|null $sourceResourceSet |