Completed
Push — master ( 0cfd9b...0455f1 )
by André
27:37
created

SwapLocation::receive()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 16
rs 9.4285
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\Search\Common\Slot;
12
use eZ\Publish\Core\SignalSlot\Signal;
13
14
/**
15
 * A Search Engine slot handling SwapLocationSignal.
16
 */
17
class SwapLocation extends Slot
18
{
19
    /**
20
     * Receive the given $signal and react on it.
21
     *
22
     * @param Signal $signal
23
     */
24
    public function receive(Signal $signal)
25
    {
26
        if (!$signal instanceof Signal\LocationService\SwapLocationSignal) {
27
            return;
28
        }
29
        $content1Info = $this->persistenceHandler->contentHandler()->loadContentInfo($signal->content1Id);
30
        $content2Info = $this->persistenceHandler->contentHandler()->loadContentInfo($signal->content2Id);
31
        $this->searchHandler->indexContent(
32
            $this->persistenceHandler->contentHandler()->load($content1Info->id, $content1Info->currentVersionNo)
33
        );
34
        $this->searchHandler->indexContent(
35
            $this->persistenceHandler->contentHandler()->load($content2Info->id, $content2Info->currentVersionNo)
36
        );
37
        $this->searchHandler->indexLocation($this->persistenceHandler->locationHandler()->load($signal->location1Id));
38
        $this->searchHandler->indexLocation($this->persistenceHandler->locationHandler()->load($signal->location2Id));
39
    }
40
}
41