| @@ 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. |
|
| @@ 553-572 (lines=20) @@ | ||
| 550 | * |
|
| 551 | * @return \eZ\Publish\Core\REST\Server\Values\NoContent |
|
| 552 | */ |
|
| 553 | public function deletePolicy($roleId, $policyId, Request $request) |
|
| 554 | { |
|
| 555 | $role = $this->roleService->loadRole($roleId); |
|
| 556 | ||
| 557 | $policy = null; |
|
| 558 | foreach ($role->getPolicies() as $rolePolicy) { |
|
| 559 | if ($rolePolicy->id == $policyId) { |
|
| 560 | $policy = $rolePolicy; |
|
| 561 | break; |
|
| 562 | } |
|
| 563 | } |
|
| 564 | ||
| 565 | if ($policy !== null) { |
|
| 566 | $this->roleService->deletePolicy($policy); |
|
| 567 | ||
| 568 | return new Values\NoContent(); |
|
| 569 | } |
|
| 570 | ||
| 571 | throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'."); |
|
| 572 | } |
|
| 573 | ||
| 574 | /** |
|
| 575 | * Remove a policy from a role draft. |
|
| @@ 586-605 (lines=20) @@ | ||
| 583 | * |
|
| 584 | * @return \eZ\Publish\Core\REST\Server\Values\NoContent |
|
| 585 | */ |
|
| 586 | public function removePolicyByRoleDraft($roleId, $policyId, Request $request) |
|
| 587 | { |
|
| 588 | $roleDraft = $this->roleService->loadRoleDraft($roleId); |
|
| 589 | ||
| 590 | $policy = null; |
|
| 591 | foreach ($roleDraft->getPolicies() as $rolePolicy) { |
|
| 592 | if ($rolePolicy->id == $policyId) { |
|
| 593 | $policy = $rolePolicy; |
|
| 594 | break; |
|
| 595 | } |
|
| 596 | } |
|
| 597 | ||
| 598 | if ($policy !== null) { |
|
| 599 | $this->roleService->removePolicyByRoleDraft($roleDraft, $policy); |
|
| 600 | ||
| 601 | return new Values\NoContent(); |
|
| 602 | } |
|
| 603 | ||
| 604 | throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'."); |
|
| 605 | } |
|
| 606 | ||
| 607 | /** |
|
| 608 | * Assigns role to user. |
|