Code Duplication    Length = 36-40 lines in 3 locations

eZ/Publish/Core/Search/Common/Slot/CreateUser.php 1 location

@@ 22-61 (lines=40) @@
19
/**
20
 * A Search Engine slot handling CreateUserSignal.
21
 */
22
class CreateUser extends Slot
23
{
24
    /**
25
     * Receive the given $signal and react on it.
26
     *
27
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
28
     */
29
    public function receive(Signal $signal)
30
    {
31
        if (!$signal instanceof Signal\UserService\CreateUserSignal) {
32
            return;
33
        }
34
35
        if (!$this->searchHandler instanceof Indexer) {
36
            return;
37
        }
38
39
        $userContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
40
            $signal->userId
41
        );
42
43
        if ($this->searchHandler instanceof ContentIndexer) {
44
            $this->searchHandler->indexContent(
45
                $this->persistenceHandler->contentHandler()->load(
46
                    $userContentInfo->id,
47
                    $userContentInfo->currentVersionNo
48
                )
49
            );
50
        }
51
52
        if ($this->searchHandler instanceof LocationIndexer) {
53
            $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
54
                $userContentInfo->id
55
            );
56
            foreach ($locations as $location) {
57
                $this->searchHandler->indexLocation($location);
58
            }
59
        }
60
    }
61
}
62

eZ/Publish/Core/Search/Common/Slot/CreateUserGroup.php 1 location

@@ 22-61 (lines=40) @@
19
/**
20
 * A Search Engine slot handling CreateUserGroupSignal.
21
 */
22
class CreateUserGroup extends Slot
23
{
24
    /**
25
     * Receive the given $signal and react on it.
26
     *
27
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
28
     */
29
    public function receive(Signal $signal)
30
    {
31
        if (!$signal instanceof Signal\UserService\CreateUserGroupSignal) {
32
            return;
33
        }
34
35
        if (!$this->searchHandler instanceof Indexer) {
36
            return;
37
        }
38
39
        $userGroupContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
40
            $signal->userGroupId
41
        );
42
43
        if ($this->searchHandler instanceof ContentIndexer) {
44
            $this->searchHandler->indexContent(
45
                $this->persistenceHandler->contentHandler()->load(
46
                    $userGroupContentInfo->id,
47
                    $userGroupContentInfo->currentVersionNo
48
                )
49
            );
50
        }
51
52
        if ($this->searchHandler instanceof LocationIndexer) {
53
            $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
54
                $userGroupContentInfo->id
55
            );
56
            foreach ($locations as $location) {
57
                $this->searchHandler->indexLocation($location);
58
            }
59
        }
60
    }
61
}
62

eZ/Publish/Core/Search/Common/Slot/SetContentState.php 1 location

@@ 22-57 (lines=36) @@
19
/**
20
 * A Search Engine slot handling SetContentStateSignal.
21
 */
22
class SetContentState extends Slot
23
{
24
    /**
25
     * Receive the given $signal and react on it.
26
     *
27
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
28
     */
29
    public function receive(Signal $signal)
30
    {
31
        if (!$signal instanceof Signal\ObjectStateService\SetContentStateSignal) {
32
            return;
33
        }
34
35
        if (!$this->searchHandler instanceof Indexer) {
36
            return;
37
        }
38
39
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($signal->contentId);
40
41
        if ($this->searchHandler instanceof ContentIndexer) {
42
            $this->searchHandler->indexContent(
43
                $this->persistenceHandler->contentHandler()->load(
44
                    $contentInfo->id,
45
                    $contentInfo->currentVersionNo
46
                )
47
            );
48
        }
49
50
        if ($this->searchHandler instanceof LocationIndexer) {
51
            $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($contentInfo->id);
52
            foreach ($locations as $location) {
53
                $this->searchHandler->indexLocation($location);
54
            }
55
        }
56
    }
57
}
58