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

PublishVersion::receive()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 19
Code Lines 10

Duplication

Lines 19
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 10
c 1
b 0
f 0
nc 7
nop 1
dl 19
loc 19
rs 8.8571
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 PublishVersionSignal.
20
 */
21 View Code Duplication
class PublishVersion 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\PublishVersionSignal) {
31
            return;
32
        }
33
34
        if ($this->searchHandler instanceof ContentIndexer) {
35
            $this->searchHandler->indexContent(
36
                $this->persistenceHandler->contentHandler()->load($signal->contentId, $signal->versionNo)
37
            );
38
        }
39
40
        if ($this->searchHandler instanceof LocationIndexer) {
41
            $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($signal->contentId);
42
            foreach ($locations as $location) {
43
                $this->searchHandler->indexLocation($location);
44
            }
45
        }
46
    }
47
}
48