Code Duplication    Length = 20-22 lines in 2 locations

eZ/Publish/Core/REST/Server/Controller/ContentType.php 1 location

@@ 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.

eZ/Publish/Core/REST/Server/Controller/Role.php 1 location

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