|
@@ 295-313 (lines=19) @@
|
| 292 |
|
* |
| 293 |
|
* @return object|null The new resource value if it is assignable or throw exception for null. |
| 294 |
|
*/ |
| 295 |
|
public function updateResource( |
| 296 |
|
ResourceSet $sourceResourceSet, |
| 297 |
|
$sourceEntityInstance, |
| 298 |
|
KeyDescriptor $keyDescriptor, |
| 299 |
|
$data, |
| 300 |
|
$shouldUpdate = false |
| 301 |
|
) { |
| 302 |
|
$verb = 'update'; |
| 303 |
|
$class = get_class($sourceEntityInstance); |
| 304 |
|
|
| 305 |
|
$data = $this->createUpdateDeleteCore($sourceEntityInstance, $data, $class, $verb); |
| 306 |
|
|
| 307 |
|
$success = isset($data['id']); |
| 308 |
|
|
| 309 |
|
if ($success) { |
| 310 |
|
return $class::findOrFail($data['id']); |
| 311 |
|
} |
| 312 |
|
throw new ODataException('Target model not successfully updated', 422); |
| 313 |
|
} |
| 314 |
|
/** |
| 315 |
|
* Delete resource from a resource set. |
| 316 |
|
* @param ResourceSet|null $resourceSet |
|
@@ 321-335 (lines=15) @@
|
| 318 |
|
* |
| 319 |
|
* return bool true if resources sucessfully deteled, otherwise false. |
| 320 |
|
*/ |
| 321 |
|
public function deleteResource( |
| 322 |
|
ResourceSet $sourceResourceSet, |
| 323 |
|
$sourceEntityInstance |
| 324 |
|
) { |
| 325 |
|
$verb = 'delete'; |
| 326 |
|
$class = get_class($sourceEntityInstance); |
| 327 |
|
|
| 328 |
|
$data = $this->createUpdateDeleteCore($sourceEntityInstance, null, $class, $verb); |
| 329 |
|
|
| 330 |
|
$success = isset($data['id']); |
| 331 |
|
if ($success) { |
| 332 |
|
return $class::findOrFail($data['id']); |
| 333 |
|
} |
| 334 |
|
throw new ODataException('Target model not successfully deleted', 422); |
| 335 |
|
} |
| 336 |
|
/** |
| 337 |
|
* @param ResourceSet $resourceSet The entity set containing the entity to fetch |
| 338 |
|
* @param object $sourceEntityInstance The source entity instance |
|
@@ 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 = get_class($sourceEntityInstance); |
| 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 |