Code Duplication    Length = 23-25 lines in 22 locations

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

@@ 331-353 (lines=23) @@
328
        return $relation;
329
    }
330
331
    public function deleteRelation(
332
        VersionInfo $sourceVersion,
333
        ContentInfo $destinationContent
334
    ): void {
335
        $eventData = [
336
            $sourceVersion,
337
            $destinationContent,
338
        ];
339
340
        $beforeEvent = new BeforeDeleteRelationEvent(...$eventData);
341
342
        $this->eventDispatcher->dispatch($beforeEvent, BeforeDeleteRelationEventInterface::class);
343
        if ($beforeEvent->isPropagationStopped()) {
344
            return;
345
        }
346
347
        $this->innerService->deleteRelation($sourceVersion, $destinationContent);
348
349
        $this->eventDispatcher->dispatch(
350
            new DeleteRelationEvent(...$eventData),
351
            DeleteRelationEventInterface::class
352
        );
353
    }
354
355
    public function deleteTranslation(
356
        ContentInfo $contentInfo,
@@ 355-377 (lines=23) @@
352
        );
353
    }
354
355
    public function deleteTranslation(
356
        ContentInfo $contentInfo,
357
        $languageCode
358
    ): void {
359
        $eventData = [
360
            $contentInfo,
361
            $languageCode,
362
        ];
363
364
        $beforeEvent = new BeforeDeleteTranslationEvent(...$eventData);
365
366
        $this->eventDispatcher->dispatch($beforeEvent, BeforeDeleteTranslationEventInterface::class);
367
        if ($beforeEvent->isPropagationStopped()) {
368
            return;
369
        }
370
371
        $this->innerService->deleteTranslation($contentInfo, $languageCode);
372
373
        $this->eventDispatcher->dispatch(
374
            new DeleteTranslationEvent(...$eventData),
375
            DeleteTranslationEventInterface::class
376
        );
377
    }
378
379
    public function hideContent(ContentInfo $contentInfo): void
380
    {

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

@@ 123-145 (lines=23) @@
120
        return $contentTypeGroup;
121
    }
122
123
    public function updateContentTypeGroup(
124
        ContentTypeGroup $contentTypeGroup,
125
        ContentTypeGroupUpdateStruct $contentTypeGroupUpdateStruct
126
    ): void {
127
        $eventData = [
128
            $contentTypeGroup,
129
            $contentTypeGroupUpdateStruct,
130
        ];
131
132
        $beforeEvent = new BeforeUpdateContentTypeGroupEvent(...$eventData);
133
134
        $this->eventDispatcher->dispatch($beforeEvent, BeforeUpdateContentTypeGroupEventInterface::class);
135
        if ($beforeEvent->isPropagationStopped()) {
136
            return;
137
        }
138
139
        $this->innerService->updateContentTypeGroup($contentTypeGroup, $contentTypeGroupUpdateStruct);
140
141
        $this->eventDispatcher->dispatch(
142
            new UpdateContentTypeGroupEvent(...$eventData),
143
            UpdateContentTypeGroupEventInterface::class
144
        );
145
    }
146
147
    public function deleteContentTypeGroup(ContentTypeGroup $contentTypeGroup): void
148
    {
@@ 217-239 (lines=23) @@
214
        return $contentTypeDraft;
215
    }
216
217
    public function updateContentTypeDraft(
218
        ContentTypeDraft $contentTypeDraft,
219
        ContentTypeUpdateStruct $contentTypeUpdateStruct
220
    ): void {
221
        $eventData = [
222
            $contentTypeDraft,
223
            $contentTypeUpdateStruct,
224
        ];
225
226
        $beforeEvent = new BeforeUpdateContentTypeDraftEvent(...$eventData);
227
228
        $this->eventDispatcher->dispatch($beforeEvent, BeforeUpdateContentTypeDraftEventInterface::class);
229
        if ($beforeEvent->isPropagationStopped()) {
230
            return;
231
        }
232
233
        $this->innerService->updateContentTypeDraft($contentTypeDraft, $contentTypeUpdateStruct);
234
235
        $this->eventDispatcher->dispatch(
236
            new UpdateContentTypeDraftEvent(...$eventData),
237
            UpdateContentTypeDraftEventInterface::class
238
        );
239
    }
240
241
    public function deleteContentType(ContentType $contentType): void
242
    {
@@ 288-310 (lines=23) @@
285
        return $contentTypeCopy;
286
    }
287
288
    public function assignContentTypeGroup(
289
        ContentType $contentType,
290
        ContentTypeGroup $contentTypeGroup
291
    ): void {
292
        $eventData = [
293
            $contentType,
294
            $contentTypeGroup,
295
        ];
296
297
        $beforeEvent = new BeforeAssignContentTypeGroupEvent(...$eventData);
298
299
        $this->eventDispatcher->dispatch($beforeEvent, BeforeAssignContentTypeGroupEventInterface::class);
300
        if ($beforeEvent->isPropagationStopped()) {
301
            return;
302
        }
303
304
        $this->innerService->assignContentTypeGroup($contentType, $contentTypeGroup);
305
306
        $this->eventDispatcher->dispatch(
307
            new AssignContentTypeGroupEvent(...$eventData),
308
            AssignContentTypeGroupEventInterface::class
309
        );
310
    }
311
312
    public function unassignContentTypeGroup(
313
        ContentType $contentType,
@@ 312-334 (lines=23) @@
309
        );
310
    }
311
312
    public function unassignContentTypeGroup(
313
        ContentType $contentType,
314
        ContentTypeGroup $contentTypeGroup
315
    ): void {
316
        $eventData = [
317
            $contentType,
318
            $contentTypeGroup,
319
        ];
320
321
        $beforeEvent = new BeforeUnassignContentTypeGroupEvent(...$eventData);
322
323
        $this->eventDispatcher->dispatch($beforeEvent, BeforeUnassignContentTypeGroupEventInterface::class);
324
        if ($beforeEvent->isPropagationStopped()) {
325
            return;
326
        }
327
328
        $this->innerService->unassignContentTypeGroup($contentType, $contentTypeGroup);
329
330
        $this->eventDispatcher->dispatch(
331
            new UnassignContentTypeGroupEvent(...$eventData),
332
            UnassignContentTypeGroupEventInterface::class
333
        );
334
    }
335
336
    public function addFieldDefinition(
337
        ContentTypeDraft $contentTypeDraft,
@@ 336-358 (lines=23) @@
333
        );
334
    }
335
336
    public function addFieldDefinition(
337
        ContentTypeDraft $contentTypeDraft,
338
        FieldDefinitionCreateStruct $fieldDefinitionCreateStruct
339
    ): void {
340
        $eventData = [
341
            $contentTypeDraft,
342
            $fieldDefinitionCreateStruct,
343
        ];
344
345
        $beforeEvent = new BeforeAddFieldDefinitionEvent(...$eventData);
346
347
        $this->eventDispatcher->dispatch($beforeEvent, BeforeAddFieldDefinitionEventInterface::class);
348
        if ($beforeEvent->isPropagationStopped()) {
349
            return;
350
        }
351
352
        $this->innerService->addFieldDefinition($contentTypeDraft, $fieldDefinitionCreateStruct);
353
354
        $this->eventDispatcher->dispatch(
355
            new AddFieldDefinitionEvent(...$eventData),
356
            AddFieldDefinitionEventInterface::class
357
        );
358
    }
359
360
    public function removeFieldDefinition(
361
        ContentTypeDraft $contentTypeDraft,
@@ 360-382 (lines=23) @@
357
        );
358
    }
359
360
    public function removeFieldDefinition(
361
        ContentTypeDraft $contentTypeDraft,
362
        FieldDefinition $fieldDefinition
363
    ): void {
364
        $eventData = [
365
            $contentTypeDraft,
366
            $fieldDefinition,
367
        ];
368
369
        $beforeEvent = new BeforeRemoveFieldDefinitionEvent(...$eventData);
370
371
        $this->eventDispatcher->dispatch($beforeEvent, BeforeRemoveFieldDefinitionEventInterface::class);
372
        if ($beforeEvent->isPropagationStopped()) {
373
            return;
374
        }
375
376
        $this->innerService->removeFieldDefinition($contentTypeDraft, $fieldDefinition);
377
378
        $this->eventDispatcher->dispatch(
379
            new RemoveFieldDefinitionEvent(...$eventData),
380
            RemoveFieldDefinitionEventInterface::class
381
        );
382
    }
383
384
    public function updateFieldDefinition(
385
        ContentTypeDraft $contentTypeDraft,
@@ 384-408 (lines=25) @@
381
        );
382
    }
383
384
    public function updateFieldDefinition(
385
        ContentTypeDraft $contentTypeDraft,
386
        FieldDefinition $fieldDefinition,
387
        FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct
388
    ): void {
389
        $eventData = [
390
            $contentTypeDraft,
391
            $fieldDefinition,
392
            $fieldDefinitionUpdateStruct,
393
        ];
394
395
        $beforeEvent = new BeforeUpdateFieldDefinitionEvent(...$eventData);
396
397
        $this->eventDispatcher->dispatch($beforeEvent, BeforeUpdateFieldDefinitionEventInterface::class);
398
        if ($beforeEvent->isPropagationStopped()) {
399
            return;
400
        }
401
402
        $this->innerService->updateFieldDefinition($contentTypeDraft, $fieldDefinition, $fieldDefinitionUpdateStruct);
403
404
        $this->eventDispatcher->dispatch(
405
            new UpdateFieldDefinitionEvent(...$eventData),
406
            UpdateFieldDefinitionEventInterface::class
407
        );
408
    }
409
410
    public function publishContentTypeDraft(ContentTypeDraft $contentTypeDraft): void
411
    {

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

@@ 149-171 (lines=23) @@
146
        return $updatedLocation;
147
    }
148
149
    public function swapLocation(
150
        Location $location1,
151
        Location $location2
152
    ): void {
153
        $eventData = [
154
            $location1,
155
            $location2,
156
        ];
157
158
        $beforeEvent = new BeforeSwapLocationEvent(...$eventData);
159
160
        $this->eventDispatcher->dispatch($beforeEvent, BeforeSwapLocationEventInterface::class);
161
        if ($beforeEvent->isPropagationStopped()) {
162
            return;
163
        }
164
165
        $this->innerService->swapLocation($location1, $location2);
166
167
        $this->eventDispatcher->dispatch(
168
            new SwapLocationEvent(...$eventData),
169
            SwapLocationEventInterface::class
170
        );
171
    }
172
173
    public function hideLocation(Location $location): Location
174
    {
@@ 219-241 (lines=23) @@
216
        return $revealedLocation;
217
    }
218
219
    public function moveSubtree(
220
        Location $location,
221
        Location $newParentLocation
222
    ): void {
223
        $eventData = [
224
            $location,
225
            $newParentLocation,
226
        ];
227
228
        $beforeEvent = new BeforeMoveSubtreeEvent(...$eventData);
229
230
        $this->eventDispatcher->dispatch($beforeEvent, BeforeMoveSubtreeEventInterface::class);
231
        if ($beforeEvent->isPropagationStopped()) {
232
            return;
233
        }
234
235
        $this->innerService->moveSubtree($location, $newParentLocation);
236
237
        $this->eventDispatcher->dispatch(
238
            new MoveSubtreeEvent(...$eventData),
239
            MoveSubtreeEventInterface::class
240
        );
241
    }
242
243
    public function deleteLocation(Location $location): void
244
    {

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

@@ 194-216 (lines=23) @@
191
        return $updatedObjectState;
192
    }
193
194
    public function setPriorityOfObjectState(
195
        ObjectState $objectState,
196
        $priority
197
    ): void {
198
        $eventData = [
199
            $objectState,
200
            $priority,
201
        ];
202
203
        $beforeEvent = new BeforeSetPriorityOfObjectStateEvent(...$eventData);
204
205
        $this->eventDispatcher->dispatch($beforeEvent, BeforeSetPriorityOfObjectStateEventInterface::class);
206
        if ($beforeEvent->isPropagationStopped()) {
207
            return;
208
        }
209
210
        $this->innerService->setPriorityOfObjectState($objectState, $priority);
211
212
        $this->eventDispatcher->dispatch(
213
            new SetPriorityOfObjectStateEvent(...$eventData),
214
            SetPriorityOfObjectStateEventInterface::class
215
        );
216
    }
217
218
    public function deleteObjectState(ObjectState $objectState): void
219
    {
@@ 237-261 (lines=25) @@
234
        );
235
    }
236
237
    public function setContentState(
238
        ContentInfo $contentInfo,
239
        ObjectStateGroup $objectStateGroup,
240
        ObjectState $objectState
241
    ): void {
242
        $eventData = [
243
            $contentInfo,
244
            $objectStateGroup,
245
            $objectState,
246
        ];
247
248
        $beforeEvent = new BeforeSetContentStateEvent(...$eventData);
249
250
        $this->eventDispatcher->dispatch($beforeEvent, BeforeSetContentStateEventInterface::class);
251
        if ($beforeEvent->isPropagationStopped()) {
252
            return;
253
        }
254
255
        $this->innerService->setContentState($contentInfo, $objectStateGroup, $objectState);
256
257
        $this->eventDispatcher->dispatch(
258
            new SetContentStateEvent(...$eventData),
259
            SetContentStateEventInterface::class
260
        );
261
    }
262
}
263

eZ/Publish/Core/Event/RoleService.php 4 locations

@@ 433-457 (lines=25) @@
430
        );
431
    }
432
433
    public function assignRoleToUserGroup(
434
        Role $role,
435
        UserGroup $userGroup,
436
        RoleLimitation $roleLimitation = null
437
    ): void {
438
        $eventData = [
439
            $role,
440
            $userGroup,
441
            $roleLimitation,
442
        ];
443
444
        $beforeEvent = new BeforeAssignRoleToUserGroupEvent(...$eventData);
445
446
        $this->eventDispatcher->dispatch($beforeEvent, BeforeAssignRoleToUserGroupEventInterface::class);
447
        if ($beforeEvent->isPropagationStopped()) {
448
            return;
449
        }
450
451
        $this->innerService->assignRoleToUserGroup($role, $userGroup, $roleLimitation);
452
453
        $this->eventDispatcher->dispatch(
454
            new AssignRoleToUserGroupEvent(...$eventData),
455
            AssignRoleToUserGroupEventInterface::class
456
        );
457
    }
458
459
    public function unassignRoleFromUserGroup(
460
        Role $role,
@@ 459-481 (lines=23) @@
456
        );
457
    }
458
459
    public function unassignRoleFromUserGroup(
460
        Role $role,
461
        UserGroup $userGroup
462
    ): void {
463
        $eventData = [
464
            $role,
465
            $userGroup,
466
        ];
467
468
        $beforeEvent = new BeforeUnassignRoleFromUserGroupEvent(...$eventData);
469
470
        $this->eventDispatcher->dispatch($beforeEvent, BeforeUnassignRoleFromUserGroupEventInterface::class);
471
        if ($beforeEvent->isPropagationStopped()) {
472
            return;
473
        }
474
475
        $this->innerService->unassignRoleFromUserGroup($role, $userGroup);
476
477
        $this->eventDispatcher->dispatch(
478
            new UnassignRoleFromUserGroupEvent(...$eventData),
479
            UnassignRoleFromUserGroupEventInterface::class
480
        );
481
    }
482
483
    public function assignRoleToUser(
484
        Role $role,
@@ 483-507 (lines=25) @@
480
        );
481
    }
482
483
    public function assignRoleToUser(
484
        Role $role,
485
        User $user,
486
        RoleLimitation $roleLimitation = null
487
    ): void {
488
        $eventData = [
489
            $role,
490
            $user,
491
            $roleLimitation,
492
        ];
493
494
        $beforeEvent = new BeforeAssignRoleToUserEvent(...$eventData);
495
496
        $this->eventDispatcher->dispatch($beforeEvent, BeforeAssignRoleToUserEventInterface::class);
497
        if ($beforeEvent->isPropagationStopped()) {
498
            return;
499
        }
500
501
        $this->innerService->assignRoleToUser($role, $user, $roleLimitation);
502
503
        $this->eventDispatcher->dispatch(
504
            new AssignRoleToUserEvent(...$eventData),
505
            AssignRoleToUserEventInterface::class
506
        );
507
    }
508
509
    public function unassignRoleFromUser(
510
        Role $role,
@@ 509-531 (lines=23) @@
506
        );
507
    }
508
509
    public function unassignRoleFromUser(
510
        Role $role,
511
        User $user
512
    ): void {
513
        $eventData = [
514
            $role,
515
            $user,
516
        ];
517
518
        $beforeEvent = new BeforeUnassignRoleFromUserEvent(...$eventData);
519
520
        $this->eventDispatcher->dispatch($beforeEvent, BeforeUnassignRoleFromUserEventInterface::class);
521
        if ($beforeEvent->isPropagationStopped()) {
522
            return;
523
        }
524
525
        $this->innerService->unassignRoleFromUser($role, $user);
526
527
        $this->eventDispatcher->dispatch(
528
            new UnassignRoleFromUserEvent(...$eventData),
529
            UnassignRoleFromUserEventInterface::class
530
        );
531
    }
532
533
    public function removeRoleAssignment(RoleAssignment $roleAssignment): void
534
    {

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

@@ 105-127 (lines=23) @@
102
        return $updatedSection;
103
    }
104
105
    public function assignSection(
106
        ContentInfo $contentInfo,
107
        Section $section
108
    ): void {
109
        $eventData = [
110
            $contentInfo,
111
            $section,
112
        ];
113
114
        $beforeEvent = new BeforeAssignSectionEvent(...$eventData);
115
116
        $this->eventDispatcher->dispatch($beforeEvent, BeforeAssignSectionEventInterface::class);
117
        if ($beforeEvent->isPropagationStopped()) {
118
            return;
119
        }
120
121
        $this->innerService->assignSection($contentInfo, $section);
122
123
        $this->eventDispatcher->dispatch(
124
            new AssignSectionEvent(...$eventData),
125
            AssignSectionEventInterface::class
126
        );
127
    }
128
129
    public function assignSectionToSubtree(
130
        Location $location,
@@ 129-151 (lines=23) @@
126
        );
127
    }
128
129
    public function assignSectionToSubtree(
130
        Location $location,
131
        Section $section
132
    ): void {
133
        $eventData = [
134
            $location,
135
            $section,
136
        ];
137
138
        $beforeEvent = new BeforeAssignSectionToSubtreeEvent(...$eventData);
139
140
        $this->eventDispatcher->dispatch($beforeEvent, BeforeAssignSectionToSubtreeEventInterface::class);
141
        if ($beforeEvent->isPropagationStopped()) {
142
            return;
143
        }
144
145
        $this->innerService->assignSectionToSubtree($location, $section);
146
147
        $this->eventDispatcher->dispatch(
148
            new AssignSectionToSubtreeEvent(...$eventData),
149
            AssignSectionToSubtreeEventInterface::class
150
        );
151
    }
152
153
    public function deleteSection(Section $section): void
154
    {

eZ/Publish/Core/Event/UserService.php 3 locations

@@ 127-149 (lines=23) @@
124
        return $locations;
125
    }
126
127
    public function moveUserGroup(
128
        UserGroup $userGroup,
129
        UserGroup $newParent
130
    ): void {
131
        $eventData = [
132
            $userGroup,
133
            $newParent,
134
        ];
135
136
        $beforeEvent = new BeforeMoveUserGroupEvent(...$eventData);
137
138
        $this->eventDispatcher->dispatch($beforeEvent, BeforeMoveUserGroupEventInterface::class);
139
        if ($beforeEvent->isPropagationStopped()) {
140
            return;
141
        }
142
143
        $this->innerService->moveUserGroup($userGroup, $newParent);
144
145
        $this->eventDispatcher->dispatch(
146
            new MoveUserGroupEvent(...$eventData),
147
            MoveUserGroupEventInterface::class
148
        );
149
    }
150
151
    public function updateUserGroup(
152
        UserGroup $userGroup,
@@ 286-308 (lines=23) @@
283
        return $updatedUser;
284
    }
285
286
    public function assignUserToUserGroup(
287
        User $user,
288
        UserGroup $userGroup
289
    ): void {
290
        $eventData = [
291
            $user,
292
            $userGroup,
293
        ];
294
295
        $beforeEvent = new BeforeAssignUserToUserGroupEvent(...$eventData);
296
297
        $this->eventDispatcher->dispatch($beforeEvent, BeforeAssignUserToUserGroupEventInterface::class);
298
        if ($beforeEvent->isPropagationStopped()) {
299
            return;
300
        }
301
302
        $this->innerService->assignUserToUserGroup($user, $userGroup);
303
304
        $this->eventDispatcher->dispatch(
305
            new AssignUserToUserGroupEvent(...$eventData),
306
            AssignUserToUserGroupEventInterface::class
307
        );
308
    }
309
310
    public function unAssignUserFromUserGroup(
311
        User $user,
@@ 310-332 (lines=23) @@
307
        );
308
    }
309
310
    public function unAssignUserFromUserGroup(
311
        User $user,
312
        UserGroup $userGroup
313
    ): void {
314
        $eventData = [
315
            $user,
316
            $userGroup,
317
        ];
318
319
        $beforeEvent = new BeforeUnAssignUserFromUserGroupEvent(...$eventData);
320
321
        $this->eventDispatcher->dispatch($beforeEvent, BeforeUnAssignUserFromUserGroupEventInterface::class);
322
        if ($beforeEvent->isPropagationStopped()) {
323
            return;
324
        }
325
326
        $this->innerService->unAssignUserFromUserGroup($user, $userGroup);
327
328
        $this->eventDispatcher->dispatch(
329
            new UnAssignUserFromUserGroupEvent(...$eventData),
330
            UnAssignUserFromUserGroupEventInterface::class
331
        );
332
    }
333
}
334