| @@ 501-512 (lines=12) @@ | ||
| 498 | try { |
|
| 499 | // First try to treat $roleId as a role draft ID. |
|
| 500 | $role = $this->roleService->loadRoleDraft($roleId); |
|
| 501 | foreach ($role->getPolicies() as $policy) { |
|
| 502 | if ($policy->id == $policyId) { |
|
| 503 | try { |
|
| 504 | return $this->roleService->updatePolicy( |
|
| 505 | $policy, |
|
| 506 | $updateStruct |
|
| 507 | ); |
|
| 508 | } catch (LimitationValidationException $e) { |
|
| 509 | throw new BadRequestException($e->getMessage()); |
|
| 510 | } |
|
| 511 | } |
|
| 512 | } |
|
| 513 | } catch (NotFoundException $e) { |
|
| 514 | // Then try to treat $roleId as a role ID. |
|
| 515 | $role = $this->roleService->loadRole($roleId); |
|
| @@ 516-527 (lines=12) @@ | ||
| 513 | } catch (NotFoundException $e) { |
|
| 514 | // Then try to treat $roleId as a role ID. |
|
| 515 | $role = $this->roleService->loadRole($roleId); |
|
| 516 | foreach ($role->getPolicies() as $policy) { |
|
| 517 | if ($policy->id == $policyId) { |
|
| 518 | try { |
|
| 519 | return $this->roleService->updatePolicy( |
|
| 520 | $policy, |
|
| 521 | $updateStruct |
|
| 522 | ); |
|
| 523 | } catch (LimitationValidationException $e) { |
|
| 524 | throw new BadRequestException($e->getMessage()); |
|
| 525 | } |
|
| 526 | } |
|
| 527 | } |
|
| 528 | } |
|
| 529 | ||
| 530 | throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'."); |
|
| @@ 556-567 (lines=12) @@ | ||
| 553 | ); |
|
| 554 | ||
| 555 | $role = $this->roleService->loadRoleDraft($roleId); |
|
| 556 | foreach ($role->getPolicies() as $policy) { |
|
| 557 | if ($policy->id == $policyId) { |
|
| 558 | try { |
|
| 559 | return $this->roleService->updatePolicy( |
|
| 560 | $policy, |
|
| 561 | $updateStruct |
|
| 562 | ); |
|
| 563 | } catch (LimitationValidationException $e) { |
|
| 564 | throw new BadRequestException($e->getMessage()); |
|
| 565 | } |
|
| 566 | } |
|
| 567 | } |
|
| 568 | ||
| 569 | throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'."); |
|
| 570 | } |
|