Code Duplication    Length = 21-23 lines in 14 locations

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

@@ 286-306 (lines=21) @@
283
        return $relation;
284
    }
285
286
    public function deleteRelation(
287
        VersionInfo $sourceVersion,
288
        ContentInfo $destinationContent
289
    ): void {
290
        $eventData = [
291
            $sourceVersion,
292
            $destinationContent,
293
        ];
294
295
        $beforeEvent = new BeforeDeleteRelationEvent(...$eventData);
296
        if ($this->eventDispatcher->dispatch(ContentEvents::BEFORE_DELETE_RELATION, $beforeEvent)->isPropagationStopped()) {
297
            return;
298
        }
299
300
        parent::deleteRelation($sourceVersion, $destinationContent);
301
302
        $this->eventDispatcher->dispatch(
303
            ContentEvents::DELETE_RELATION,
304
            new DeleteRelationEvent(...$eventData)
305
        );
306
    }
307
308
    public function deleteTranslation(
309
        ContentInfo $contentInfo,
@@ 308-328 (lines=21) @@
305
        );
306
    }
307
308
    public function deleteTranslation(
309
        ContentInfo $contentInfo,
310
        $languageCode
311
    ): void {
312
        $eventData = [
313
            $contentInfo,
314
            $languageCode,
315
        ];
316
317
        $beforeEvent = new BeforeDeleteTranslationEvent(...$eventData);
318
        if ($this->eventDispatcher->dispatch(ContentEvents::BEFORE_DELETE_TRANSLATION, $beforeEvent)->isPropagationStopped()) {
319
            return;
320
        }
321
322
        parent::deleteTranslation($contentInfo, $languageCode);
323
324
        $this->eventDispatcher->dispatch(
325
            ContentEvents::DELETE_TRANSLATION,
326
            new DeleteTranslationEvent(...$eventData)
327
        );
328
    }
329
330
    public function hideContent(ContentInfo $contentInfo): void
331
    {

eZ/Publish/Core/Event/ContentTypeService.php 7 locations

@@ 94-114 (lines=21) @@
91
        return $contentTypeGroup;
92
    }
93
94
    public function updateContentTypeGroup(
95
        ContentTypeGroup $contentTypeGroup,
96
        ContentTypeGroupUpdateStruct $contentTypeGroupUpdateStruct
97
    ): void {
98
        $eventData = [
99
            $contentTypeGroup,
100
            $contentTypeGroupUpdateStruct,
101
        ];
102
103
        $beforeEvent = new BeforeUpdateContentTypeGroupEvent(...$eventData);
104
        if ($this->eventDispatcher->dispatch(ContentTypeEvents::BEFORE_UPDATE_CONTENT_TYPE_GROUP, $beforeEvent)->isPropagationStopped()) {
105
            return;
106
        }
107
108
        parent::updateContentTypeGroup($contentTypeGroup, $contentTypeGroupUpdateStruct);
109
110
        $this->eventDispatcher->dispatch(
111
            ContentTypeEvents::UPDATE_CONTENT_TYPE_GROUP,
112
            new UpdateContentTypeGroupEvent(...$eventData)
113
        );
114
    }
115
116
    public function deleteContentTypeGroup(ContentTypeGroup $contentTypeGroup): void
117
    {
@@ 180-200 (lines=21) @@
177
        return $contentTypeDraft;
178
    }
179
180
    public function updateContentTypeDraft(
181
        ContentTypeDraft $contentTypeDraft,
182
        ContentTypeUpdateStruct $contentTypeUpdateStruct
183
    ): void {
184
        $eventData = [
185
            $contentTypeDraft,
186
            $contentTypeUpdateStruct,
187
        ];
188
189
        $beforeEvent = new BeforeUpdateContentTypeDraftEvent(...$eventData);
190
        if ($this->eventDispatcher->dispatch(ContentTypeEvents::BEFORE_UPDATE_CONTENT_TYPE_DRAFT, $beforeEvent)->isPropagationStopped()) {
191
            return;
192
        }
193
194
        parent::updateContentTypeDraft($contentTypeDraft, $contentTypeUpdateStruct);
195
196
        $this->eventDispatcher->dispatch(
197
            ContentTypeEvents::UPDATE_CONTENT_TYPE_DRAFT,
198
            new UpdateContentTypeDraftEvent(...$eventData)
199
        );
200
    }
201
202
    public function deleteContentType(ContentType $contentType): void
203
    {
@@ 245-265 (lines=21) @@
242
        return $contentTypeCopy;
243
    }
244
245
    public function assignContentTypeGroup(
246
        ContentType $contentType,
247
        ContentTypeGroup $contentTypeGroup
248
    ): void {
249
        $eventData = [
250
            $contentType,
251
            $contentTypeGroup,
252
        ];
253
254
        $beforeEvent = new BeforeAssignContentTypeGroupEvent(...$eventData);
255
        if ($this->eventDispatcher->dispatch(ContentTypeEvents::BEFORE_ASSIGN_CONTENT_TYPE_GROUP, $beforeEvent)->isPropagationStopped()) {
256
            return;
257
        }
258
259
        parent::assignContentTypeGroup($contentType, $contentTypeGroup);
260
261
        $this->eventDispatcher->dispatch(
262
            ContentTypeEvents::ASSIGN_CONTENT_TYPE_GROUP,
263
            new AssignContentTypeGroupEvent(...$eventData)
264
        );
265
    }
266
267
    public function unassignContentTypeGroup(
268
        ContentType $contentType,
@@ 267-287 (lines=21) @@
264
        );
265
    }
266
267
    public function unassignContentTypeGroup(
268
        ContentType $contentType,
269
        ContentTypeGroup $contentTypeGroup
270
    ): void {
271
        $eventData = [
272
            $contentType,
273
            $contentTypeGroup,
274
        ];
275
276
        $beforeEvent = new BeforeUnassignContentTypeGroupEvent(...$eventData);
277
        if ($this->eventDispatcher->dispatch(ContentTypeEvents::BEFORE_UNASSIGN_CONTENT_TYPE_GROUP, $beforeEvent)->isPropagationStopped()) {
278
            return;
279
        }
280
281
        parent::unassignContentTypeGroup($contentType, $contentTypeGroup);
282
283
        $this->eventDispatcher->dispatch(
284
            ContentTypeEvents::UNASSIGN_CONTENT_TYPE_GROUP,
285
            new UnassignContentTypeGroupEvent(...$eventData)
286
        );
287
    }
288
289
    public function addFieldDefinition(
290
        ContentTypeDraft $contentTypeDraft,
@@ 289-309 (lines=21) @@
286
        );
287
    }
288
289
    public function addFieldDefinition(
290
        ContentTypeDraft $contentTypeDraft,
291
        FieldDefinitionCreateStruct $fieldDefinitionCreateStruct
292
    ): void {
293
        $eventData = [
294
            $contentTypeDraft,
295
            $fieldDefinitionCreateStruct,
296
        ];
297
298
        $beforeEvent = new BeforeAddFieldDefinitionEvent(...$eventData);
299
        if ($this->eventDispatcher->dispatch(ContentTypeEvents::BEFORE_ADD_FIELD_DEFINITION, $beforeEvent)->isPropagationStopped()) {
300
            return;
301
        }
302
303
        parent::addFieldDefinition($contentTypeDraft, $fieldDefinitionCreateStruct);
304
305
        $this->eventDispatcher->dispatch(
306
            ContentTypeEvents::ADD_FIELD_DEFINITION,
307
            new AddFieldDefinitionEvent(...$eventData)
308
        );
309
    }
310
311
    public function removeFieldDefinition(
312
        ContentTypeDraft $contentTypeDraft,
@@ 311-331 (lines=21) @@
308
        );
309
    }
310
311
    public function removeFieldDefinition(
312
        ContentTypeDraft $contentTypeDraft,
313
        FieldDefinition $fieldDefinition
314
    ): void {
315
        $eventData = [
316
            $contentTypeDraft,
317
            $fieldDefinition,
318
        ];
319
320
        $beforeEvent = new BeforeRemoveFieldDefinitionEvent(...$eventData);
321
        if ($this->eventDispatcher->dispatch(ContentTypeEvents::BEFORE_REMOVE_FIELD_DEFINITION, $beforeEvent)->isPropagationStopped()) {
322
            return;
323
        }
324
325
        parent::removeFieldDefinition($contentTypeDraft, $fieldDefinition);
326
327
        $this->eventDispatcher->dispatch(
328
            ContentTypeEvents::REMOVE_FIELD_DEFINITION,
329
            new RemoveFieldDefinitionEvent(...$eventData)
330
        );
331
    }
332
333
    public function updateFieldDefinition(
334
        ContentTypeDraft $contentTypeDraft,
@@ 333-355 (lines=23) @@
330
        );
331
    }
332
333
    public function updateFieldDefinition(
334
        ContentTypeDraft $contentTypeDraft,
335
        FieldDefinition $fieldDefinition,
336
        FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct
337
    ): void {
338
        $eventData = [
339
            $contentTypeDraft,
340
            $fieldDefinition,
341
            $fieldDefinitionUpdateStruct,
342
        ];
343
344
        $beforeEvent = new BeforeUpdateFieldDefinitionEvent(...$eventData);
345
        if ($this->eventDispatcher->dispatch(ContentTypeEvents::BEFORE_UPDATE_FIELD_DEFINITION, $beforeEvent)->isPropagationStopped()) {
346
            return;
347
        }
348
349
        parent::updateFieldDefinition($contentTypeDraft, $fieldDefinition, $fieldDefinitionUpdateStruct);
350
351
        $this->eventDispatcher->dispatch(
352
            ContentTypeEvents::UPDATE_FIELD_DEFINITION,
353
            new UpdateFieldDefinitionEvent(...$eventData)
354
        );
355
    }
356
357
    public function publishContentTypeDraft(ContentTypeDraft $contentTypeDraft): void
358
    {

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

@@ 130-150 (lines=21) @@
127
        return $updatedLocation;
128
    }
129
130
    public function swapLocation(
131
        Location $location1,
132
        Location $location2
133
    ): void {
134
        $eventData = [
135
            $location1,
136
            $location2,
137
        ];
138
139
        $beforeEvent = new BeforeSwapLocationEvent(...$eventData);
140
        if ($this->eventDispatcher->dispatch(LocationEvents::BEFORE_SWAP_LOCATION, $beforeEvent)->isPropagationStopped()) {
141
            return;
142
        }
143
144
        parent::swapLocation($location1, $location2);
145
146
        $this->eventDispatcher->dispatch(
147
            LocationEvents::SWAP_LOCATION,
148
            new SwapLocationEvent(...$eventData)
149
        );
150
    }
151
152
    public function hideLocation(Location $location): Location
153
    {
@@ 194-214 (lines=21) @@
191
        return $revealedLocation;
192
    }
193
194
    public function moveSubtree(
195
        Location $location,
196
        Location $newParentLocation
197
    ): void {
198
        $eventData = [
199
            $location,
200
            $newParentLocation,
201
        ];
202
203
        $beforeEvent = new BeforeMoveSubtreeEvent(...$eventData);
204
        if ($this->eventDispatcher->dispatch(LocationEvents::BEFORE_MOVE_SUBTREE, $beforeEvent)->isPropagationStopped()) {
205
            return;
206
        }
207
208
        parent::moveSubtree($location, $newParentLocation);
209
210
        $this->eventDispatcher->dispatch(
211
            LocationEvents::MOVE_SUBTREE,
212
            new MoveSubtreeEvent(...$eventData)
213
        );
214
    }
215
216
    public function deleteLocation(Location $location): void
217
    {

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

@@ 171-191 (lines=21) @@
168
        return $updatedObjectState;
169
    }
170
171
    public function setPriorityOfObjectState(
172
        ObjectState $objectState,
173
        $priority
174
    ): void {
175
        $eventData = [
176
            $objectState,
177
            $priority,
178
        ];
179
180
        $beforeEvent = new BeforeSetPriorityOfObjectStateEvent(...$eventData);
181
        if ($this->eventDispatcher->dispatch(ObjectStateEvents::BEFORE_SET_PRIORITY_OF_OBJECT_STATE, $beforeEvent)->isPropagationStopped()) {
182
            return;
183
        }
184
185
        parent::setPriorityOfObjectState($objectState, $priority);
186
187
        $this->eventDispatcher->dispatch(
188
            ObjectStateEvents::SET_PRIORITY_OF_OBJECT_STATE,
189
            new SetPriorityOfObjectStateEvent(...$eventData)
190
        );
191
    }
192
193
    public function deleteObjectState(ObjectState $objectState): void
194
    {
@@ 210-232 (lines=23) @@
207
        );
208
    }
209
210
    public function setContentState(
211
        ContentInfo $contentInfo,
212
        ObjectStateGroup $objectStateGroup,
213
        ObjectState $objectState
214
    ): void {
215
        $eventData = [
216
            $contentInfo,
217
            $objectStateGroup,
218
            $objectState,
219
        ];
220
221
        $beforeEvent = new BeforeSetContentStateEvent(...$eventData);
222
        if ($this->eventDispatcher->dispatch(ObjectStateEvents::BEFORE_SET_CONTENT_STATE, $beforeEvent)->isPropagationStopped()) {
223
            return;
224
        }
225
226
        parent::setContentState($contentInfo, $objectStateGroup, $objectState);
227
228
        $this->eventDispatcher->dispatch(
229
            ObjectStateEvents::SET_CONTENT_STATE,
230
            new SetContentStateEvent(...$eventData)
231
        );
232
    }
233
}
234

eZ/Publish/Core/Event/SectionService.php 1 location

@@ 116-136 (lines=21) @@
113
        );
114
    }
115
116
    public function assignSectionToSubtree(
117
        Location $location,
118
        Section $section
119
    ): void {
120
        $eventData = [
121
            $location,
122
            $section,
123
        ];
124
125
        $beforeEvent = new BeforeAssignSectionToSubtreeEvent(...$eventData);
126
        if ($this->eventDispatcher->dispatch(SectionEvents::BEFORE_ASSIGN_SECTION_TO_SUBTREE, $beforeEvent)->isPropagationStopped()) {
127
            return;
128
        }
129
130
        parent::assignSectionToSubtree($location, $section);
131
132
        $this->eventDispatcher->dispatch(
133
            SectionEvents::ASSIGN_SECTION_TO_SUBTREE,
134
            new AssignSectionToSubtreeEvent(...$eventData)
135
        );
136
    }
137
138
    public function deleteSection(Section $section)
139
    {