Code Duplication    Length = 16-25 lines in 6 locations

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

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

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

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

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

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