Code Duplication    Length = 24-24 lines in 2 locations

eZ/Publish/Core/Event/ContentService.php 2 locations

@@ 129-152 (lines=24) @@
126
        return $locations;
127
    }
128
129
    public function createContentDraft(
130
        ContentInfo $contentInfo,
131
        VersionInfo $versionInfo = null,
132
        User $creator = null
133
    ): Content {
134
        $eventData = [
135
            $contentInfo,
136
            $versionInfo,
137
            $creator,
138
        ];
139
140
        $beforeEvent = new BeforeCreateContentDraftEvent(...$eventData);
141
        if ($this->eventDispatcher->dispatch($beforeEvent)->isPropagationStopped()) {
142
            return $beforeEvent->getContentDraft();
143
        }
144
145
        $contentDraft = $beforeEvent->hasContentDraft()
146
            ? $beforeEvent->getContentDraft()
147
            : $this->innerService->createContentDraft($contentInfo, $versionInfo, $creator);
148
149
        $this->eventDispatcher->dispatch(new CreateContentDraftEvent($contentDraft, ...$eventData));
150
151
        return $contentDraft;
152
    }
153
154
    public function updateContent(
155
        VersionInfo $versionInfo,
@@ 209-232 (lines=24) @@
206
        $this->eventDispatcher->dispatch(new DeleteVersionEvent(...$eventData));
207
    }
208
209
    public function copyContent(
210
        ContentInfo $contentInfo,
211
        LocationCreateStruct $destinationLocationCreateStruct,
212
        VersionInfo $versionInfo = null
213
    ): Content {
214
        $eventData = [
215
            $contentInfo,
216
            $destinationLocationCreateStruct,
217
            $versionInfo,
218
        ];
219
220
        $beforeEvent = new BeforeCopyContentEvent(...$eventData);
221
        if ($this->eventDispatcher->dispatch($beforeEvent)->isPropagationStopped()) {
222
            return $beforeEvent->getContent();
223
        }
224
225
        $content = $beforeEvent->hasContent()
226
            ? $beforeEvent->getContent()
227
            : $this->innerService->copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo);
228
229
        $this->eventDispatcher->dispatch(new CopyContentEvent($content, ...$eventData));
230
231
        return $content;
232
    }
233
234
    public function addRelation(
235
        VersionInfo $sourceVersion,