Completed
Push — EZP-25088-search-handler-inter... ( f8bc81 )
by
unknown
26:40
created

CopyContent::receive()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 24
Code Lines 13

Duplication

Lines 24
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 13
c 1
b 0
f 0
nc 7
nop 1
dl 24
loc 24
rs 8.5125
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
 * @version //autogentag//
10
 */
11
namespace eZ\Publish\Core\Search\Common\Slot;
12
13
use eZ\Publish\Core\SignalSlot\Signal;
14
use eZ\Publish\Core\Search\Common\Slot;
15
use eZ\Publish\SPI\Search\Indexer\ContentIndexer;
16
use eZ\Publish\SPI\Search\Indexer\LocationIndexer;
17
18
/**
19
 * A Search Engine slot handling CopyContentSignal.
20
 */
21 View Code Duplication
class CopyContent 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...
22
{
23
    /**
24
     * Receive the given $signal and react on it.
25
     *
26
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
27
     */
28
    public function receive(Signal $signal)
29
    {
30
        if (!$signal instanceof Signal\ContentService\CopyContentSignal) {
31
            return;
32
        }
33
34
        if ($this->searchHandler instanceof ContentIndexer) {
35
            $this->searchHandler->indexContent(
36
                $this->persistenceHandler->contentHandler()->load(
37
                    $signal->dstContentId,
38
                    $signal->dstVersionNo
39
                )
40
            );
41
        }
42
43
        if ($this->searchHandler instanceof LocationIndexer) {
44
            $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
45
                $signal->dstContentId
46
            );
47
            foreach ($locations as $location) {
48
                $this->searchHandler->indexLocation($location);
49
            }
50
        }
51
    }
52
}
53