Completed
Push — master ( a8052f...413f40 )
by André
20:01 queued 05:56
created

RemoveTranslation::receive()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 15

Duplication

Lines 27
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 15
nc 4
nop 1
dl 27
loc 27
rs 8.5806
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the eZ Publish Kernel package.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Search\Common\Slot;
10
11
use eZ\Publish\Core\SignalSlot\Signal;
12
use eZ\Publish\Core\Search\Common\Slot;
13
14
/**
15
 * A Search Engine slot handling RemoveTranslationSignal.
16
 */
17 View Code Duplication
class RemoveTranslation extends Slot
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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