| @@ 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. |
|
| @@ 636-655 (lines=20) @@ | ||
| 633 | * |
|
| 634 | * @return \eZ\Publish\Core\REST\Server\Values\NoContent |
|
| 635 | */ |
|
| 636 | public function removePolicyByRoleDraft($roleId, $policyId, Request $request) |
|
| 637 | { |
|
| 638 | $roleDraft = $this->roleService->loadRoleDraft($roleId); |
|
| 639 | ||
| 640 | $policy = null; |
|
| 641 | foreach ($roleDraft->getPolicies() as $rolePolicy) { |
|
| 642 | if ($rolePolicy->id == $policyId) { |
|
| 643 | $policy = $rolePolicy; |
|
| 644 | break; |
|
| 645 | } |
|
| 646 | } |
|
| 647 | ||
| 648 | if ($policy !== null) { |
|
| 649 | $this->roleService->removePolicyByRoleDraft($roleDraft, $policy); |
|
| 650 | ||
| 651 | return new Values\NoContent(); |
|
| 652 | } |
|
| 653 | ||
| 654 | throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'."); |
|
| 655 | } |
|
| 656 | ||
| 657 | /** |
|
| 658 | * Assigns role to user. |
|