Code Duplication    Length = 27-35 lines in 5 locations

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

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

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

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

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

@@ 17-43 (lines=27) @@
14
/**
15
 * A Search Engine slot handling RecoverSignal.
16
 */
17
class Recover extends Slot
18
{
19
    /**
20
     * Receive the given $signal and react on it.
21
     *
22
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
23
     */
24
    public function receive(Signal $signal)
25
    {
26
        if (!$signal instanceof Signal\TrashService\RecoverSignal) {
27
            return;
28
        }
29
30
        $contentHandler = $this->persistenceHandler->contentHandler();
31
32
        foreach ($this->persistenceHandler->locationHandler()->loadSubtreeIds($signal->newLocationId) as $contentId) {
33
            $contentInfo = $contentHandler->loadContentInfo($contentId);
34
            $this->searchHandler->indexContent(
35
                $contentHandler->load($contentInfo->id, $contentInfo->currentVersionNo)
36
            );
37
38
            $this->searchHandler->indexLocation(
39
                $this->persistenceHandler->locationHandler()->load($signal->newLocationId)
40
            );
41
        }
42
    }
43
}
44

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

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

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

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