Code Duplication    Length = 16-25 lines in 6 locations

eZ/Publish/Core/Search/Common/EventSubscriber/ContentEventSubscriber.php 1 location

@@ 59-83 (lines=25) @@
56
        }
57
    }
58
59
    public function onDeleteTranslation(DeleteTranslationEvent $event)
60
    {
61
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
62
            $event->getContentInfo()->id
63
        );
64
65
        if (!$contentInfo->status === ContentInfo::STATUS_PUBLISHED) {
66
            return;
67
        }
68
69
        $this->searchHandler->indexContent(
70
            $this->persistenceHandler->contentHandler()->load(
71
                $contentInfo->id,
72
                $contentInfo->currentVersionNo
73
            )
74
        );
75
76
        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
77
            $contentInfo->id
78
        );
79
80
        foreach ($locations as $location) {
81
            $this->searchHandler->indexLocation($location);
82
        }
83
    }
84
85
    public function onHideContent(HideContentEvent $event)
86
    {

eZ/Publish/Core/Search/Common/EventSubscriber/ObjectStateEventSubscriber.php 1 location

@@ 18-33 (lines=16) @@
15
        ];
16
    }
17
18
    public function onSetContentState(SetContentStateEvent $event)
19
    {
20
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($event->getContentInfo()->id);
21
22
        $this->searchHandler->indexContent(
23
            $this->persistenceHandler->contentHandler()->load(
24
                $contentInfo->id,
25
                $contentInfo->currentVersionNo
26
            )
27
        );
28
29
        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($contentInfo->id);
30
        foreach ($locations as $location) {
31
            $this->searchHandler->indexLocation($location);
32
        }
33
    }
34
}

eZ/Publish/Core/Search/Common/EventSubscriber/UserEventSubscriber.php 4 locations

@@ 30-50 (lines=21) @@
27
        ];
28
    }
29
30
    public function onCreateUser(CreateUserEvent $event)
31
    {
32
        $userContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
33
            $event->getUser()->id
34
        );
35
36
        $this->searchHandler->indexContent(
37
            $this->persistenceHandler->contentHandler()->load(
38
                $userContentInfo->id,
39
                $userContentInfo->currentVersionNo
40
            )
41
        );
42
43
        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
44
            $userContentInfo->id
45
        );
46
47
        foreach ($locations as $location) {
48
            $this->searchHandler->indexLocation($location);
49
        }
50
    }
51
52
    public function onCreateUserGroup(CreateUserGroupEvent $event)
53
    {
@@ 52-72 (lines=21) @@
49
        }
50
    }
51
52
    public function onCreateUserGroup(CreateUserGroupEvent $event)
53
    {
54
        $userGroupContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
55
            $event->getUserGroup()->id
56
        );
57
58
        $this->searchHandler->indexContent(
59
            $this->persistenceHandler->contentHandler()->load(
60
                $userGroupContentInfo->id,
61
                $userGroupContentInfo->currentVersionNo
62
            )
63
        );
64
65
        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
66
            $userGroupContentInfo->id
67
        );
68
69
        foreach ($locations as $location) {
70
            $this->searchHandler->indexLocation($location);
71
        }
72
    }
73
74
    public function onDeleteUser(DeleteUserEvent $event)
75
    {
@@ 103-123 (lines=21) @@
100
        $this->indexSubtree($userGroupContentInfo->mainLocationId);
101
    }
102
103
    public function onUpdateUser(UpdateUserEvent $event)
104
    {
105
        $userContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
106
            $event->getUser()->id
107
        );
108
109
        $this->searchHandler->indexContent(
110
            $this->persistenceHandler->contentHandler()->load(
111
                $userContentInfo->id,
112
                $userContentInfo->currentVersionNo
113
            )
114
        );
115
116
        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
117
            $userContentInfo->id
118
        );
119
120
        foreach ($locations as $location) {
121
            $this->searchHandler->indexLocation($location);
122
        }
123
    }
124
125
    public function onUpdateUserGroup(UpdateUserGroupEvent $event)
126
    {
@@ 125-145 (lines=21) @@
122
        }
123
    }
124
125
    public function onUpdateUserGroup(UpdateUserGroupEvent $event)
126
    {
127
        $userContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
128
            $event->getUserGroup()->id
129
        );
130
131
        $this->searchHandler->indexContent(
132
            $this->persistenceHandler->contentHandler()->load(
133
                $userContentInfo->id,
134
                $userContentInfo->currentVersionNo
135
            )
136
        );
137
138
        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
139
            $userContentInfo->id
140
        );
141
142
        foreach ($locations as $location) {
143
            $this->searchHandler->indexLocation($location);
144
        }
145
    }
146
}