| @@ 672-693 (lines=22) @@ | ||
| 669 | * |
|
| 670 | * @return \eZ\Publish\Core\REST\Server\Values\NoContent |
|
| 671 | */ |
|
| 672 | public function removeContentTypeDraftFieldDefinition($contentTypeId, $fieldDefinitionId, Request $request) |
|
| 673 | { |
|
| 674 | $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId); |
|
| 675 | ||
| 676 | $fieldDefinition = null; |
|
| 677 | foreach ($contentTypeDraft->getFieldDefinitions() as $fieldDef) { |
|
| 678 | if ($fieldDef->id == $fieldDefinitionId) { |
|
| 679 | $fieldDefinition = $fieldDef; |
|
| 680 | } |
|
| 681 | } |
|
| 682 | ||
| 683 | if ($fieldDefinition === null) { |
|
| 684 | throw new Exceptions\NotFoundException("Field definition not found: '{$request->getPathInfo()}'."); |
|
| 685 | } |
|
| 686 | ||
| 687 | $this->contentTypeService->removeFieldDefinition( |
|
| 688 | $contentTypeDraft, |
|
| 689 | $fieldDefinition |
|
| 690 | ); |
|
| 691 | ||
| 692 | return new Values\NoContent(); |
|
| 693 | } |
|
| 694 | ||
| 695 | /** |
|
| 696 | * Publishes a content type draft. |
|
| @@ 537-556 (lines=20) @@ | ||
| 534 | * |
|
| 535 | * @return \eZ\Publish\Core\REST\Server\Values\NoContent |
|
| 536 | */ |
|
| 537 | public function deletePolicy($roleId, $policyId, Request $request) |
|
| 538 | { |
|
| 539 | $role = $this->roleService->loadRole($roleId); |
|
| 540 | ||
| 541 | $policy = null; |
|
| 542 | foreach ($role->getPolicies() as $rolePolicy) { |
|
| 543 | if ($rolePolicy->id == $policyId) { |
|
| 544 | $policy = $rolePolicy; |
|
| 545 | break; |
|
| 546 | } |
|
| 547 | } |
|
| 548 | ||
| 549 | if ($policy !== null) { |
|
| 550 | $this->roleService->deletePolicy($policy); |
|
| 551 | ||
| 552 | return new Values\NoContent(); |
|
| 553 | } |
|
| 554 | ||
| 555 | throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'."); |
|
| 556 | } |
|
| 557 | ||
| 558 | /** |
|
| 559 | * Remove a policy from a role draft. |
|
| @@ 568-587 (lines=20) @@ | ||
| 565 | * |
|
| 566 | * @return \eZ\Publish\Core\REST\Server\Values\NoContent |
|
| 567 | */ |
|
| 568 | public function removePolicyByRoleDraft($roleId, $policyId, Request $request) |
|
| 569 | { |
|
| 570 | $roleDraft = $this->roleService->loadRoleDraft($roleId); |
|
| 571 | ||
| 572 | $policy = null; |
|
| 573 | foreach ($roleDraft->getPolicies() as $rolePolicy) { |
|
| 574 | if ($rolePolicy->id == $policyId) { |
|
| 575 | $policy = $rolePolicy; |
|
| 576 | break; |
|
| 577 | } |
|
| 578 | } |
|
| 579 | ||
| 580 | if ($policy !== null) { |
|
| 581 | $this->roleService->removePolicyByRoleDraft($roleDraft, $policy); |
|
| 582 | ||
| 583 | return new Values\NoContent(); |
|
| 584 | } |
|
| 585 | ||
| 586 | throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'."); |
|
| 587 | } |
|
| 588 | ||
| 589 | /** |
|
| 590 | * Assigns role to user. |
|