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

CreateLocation::receive()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 29
Code Lines 15

Duplication

Lines 29
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 15
c 1
b 0
f 0
nc 6
nop 1
dl 29
loc 29
rs 8.439
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;
16
use eZ\Publish\SPI\Search\Indexer\ContentIndexer;
17
use eZ\Publish\SPI\Search\Indexer\LocationIndexer;
18
19
/**
20
 * A Search Engine slot handling CreateLocationSignal.
21
 */
22 View Code Duplication
class CreateLocation 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...
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\LocationService\CreateLocationSignal) {
32
            return;
33
        }
34
35
        if (!$this->searchHandler instanceof Indexer) {
36
            return;
37
        }
38
39
        $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
40
            $signal->contentId
41
        );
42
43
        if ($this->searchHandler instanceof ContentIndexer) {
44
            $this->searchHandler->indexContent(
45
                $this->persistenceHandler->contentHandler()->load(
46
                    $signal->contentId,
47
                    $contentInfo->currentVersionNo
48
                )
49
            );
50
        }
51
52
        if ($this->searchHandler instanceof LocationIndexer) {
53
            $this->searchHandler->indexLocation(
54
                $this->persistenceHandler->locationHandler()->load($signal->locationId)
55
            );
56
        }
57
    }
58
}
59