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

@@ 407-426 (lines=20) @@
404
     *
405
     * @return \eZ\Publish\Core\REST\Server\Values\NoContent
406
     */
407
    public function deletePolicy($roleId, $policyId, Request $request)
408
    {
409
        $role = $this->roleService->loadRole($roleId);
410
411
        $policy = null;
412
        foreach ($role->getPolicies() as $rolePolicy) {
413
            if ($rolePolicy->id == $policyId) {
414
                $policy = $rolePolicy;
415
                break;
416
            }
417
        }
418
419
        if ($policy !== null) {
420
            $this->roleService->deletePolicy($policy);
421
422
            return new Values\NoContent();
423
        }
424
425
        throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'.");
426
    }
427
428
    /**
429
     * Assigns role to user.