Completed
Push — ezp_30812 ( 78f0de...aab94f )
by
unknown
21:13 queued 05:34
created

DeleteUserSubscriber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\Repository\EventSubscriber;
10
11
use eZ\Publish\API\Repository\ContentTypeService;
12
use eZ\Publish\API\Repository\Events\User\DeleteUserEvent;
13
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
14
15
class DeleteUserSubscriber implements EventSubscriberInterface
16
{
17
    /** @var \eZ\Publish\API\Repository\ContentTypeService */
18
    private $contentTypeService;
19
20
    public function __construct(ContentTypeService $contentTypeService)
21
    {
22
        $this->contentTypeService = $contentTypeService;
23
    }
24
25
    public static function getSubscribedEvents(): array
26
    {
27
        return [
28
            DeleteUserEvent::class => 'onDeleteUser',
29
        ];
30
    }
31
32
    public function onDeleteUser(DeleteUserEvent $event): void
33
    {
34
        $this->contentTypeService->deleteUserDrafts($event->getUser()->id);
35
    }
36
}
37