| @@ 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. |
|
| @@ 460-479 (lines=20) @@ | ||
| 457 | * |
|
| 458 | * @return \eZ\Publish\Core\REST\Server\Values\NoContent |
|
| 459 | */ |
|
| 460 | public function deletePolicy($roleId, $policyId, Request $request) |
|
| 461 | { |
|
| 462 | $role = $this->roleService->loadRole($roleId); |
|
| 463 | ||
| 464 | $policy = null; |
|
| 465 | foreach ($role->getPolicies() as $rolePolicy) { |
|
| 466 | if ($rolePolicy->id == $policyId) { |
|
| 467 | $policy = $rolePolicy; |
|
| 468 | break; |
|
| 469 | } |
|
| 470 | } |
|
| 471 | ||
| 472 | if ($policy !== null) { |
|
| 473 | $this->roleService->deletePolicy($policy); |
|
| 474 | ||
| 475 | return new Values\NoContent(); |
|
| 476 | } |
|
| 477 | ||
| 478 | throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'."); |
|
| 479 | } |
|
| 480 | ||
| 481 | /** |
|
| 482 | * Assigns role to user. |
|