Code Duplication    Length = 23-34 lines in 2 locations

eZ/Publish/Core/Repository/ObjectStateService.php 1 location

@@ 76-109 (lines=34) @@
73
     *
74
     * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
75
     */
76
    public function createObjectStateGroup(ObjectStateGroupCreateStruct $objectStateGroupCreateStruct)
77
    {
78
        if (!$this->repository->canUser('state', 'administrate', $objectStateGroupCreateStruct)) {
79
            throw new UnauthorizedException('state', 'administrate');
80
        }
81
82
        $inputStruct = $this->buildCreateInputStruct(
83
            $objectStateGroupCreateStruct->identifier,
84
            $objectStateGroupCreateStruct->defaultLanguageCode,
85
            $objectStateGroupCreateStruct->names,
86
            $objectStateGroupCreateStruct->descriptions
87
        );
88
89
        try {
90
            $this->objectStateHandler->loadGroupByIdentifier($inputStruct->identifier);
91
            throw new InvalidArgumentException(
92
                'objectStateGroupCreateStruct',
93
                'Object state group with provided identifier already exists'
94
            );
95
        } catch (APINotFoundException $e) {
96
            // Do nothing
97
        }
98
99
        $this->repository->beginTransaction();
100
        try {
101
            $spiObjectStateGroup = $this->objectStateHandler->createGroup($inputStruct);
102
            $this->repository->commit();
103
        } catch (Exception $e) {
104
            $this->repository->rollback();
105
            throw $e;
106
        }
107
108
        return $this->buildDomainObjectStateGroupObject($spiObjectStateGroup);
109
    }
110
111
    /**
112
     * {@inheritdoc}

eZ/Publish/Core/Repository/URLService.php 1 location

@@ 88-110 (lines=23) @@
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function updateUrl(URL $url, URLUpdateStruct $struct)
89
    {
90
        if (!$this->permissionResolver->canUser('url', 'update', $url)) {
91
            throw new UnauthorizedException('url', 'update');
92
        }
93
94
        if (!$this->isUnique($url->id, $struct->url)) {
95
            throw new InvalidArgumentException('struct', 'url already exists');
96
        }
97
98
        $updateStruct = $this->buildUpdateStruct($this->loadById($url->id), $struct);
99
100
        $this->repository->beginTransaction();
101
        try {
102
            $this->urlHandler->updateUrl($url->id, $updateStruct);
103
            $this->repository->commit();
104
        } catch (Exception $e) {
105
            $this->repository->rollback();
106
            throw $e;
107
        }
108
109
        return $this->loadById($url->id);
110
    }
111
112
    /**
113
     * {@inheritdoc}