Completed
Push — EZP-25088-search-handler-inter... ( 170b1b...34d2d2 )
by
unknown
18:19
created

MoveUserGroup::receive()   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 11
c 2
b 0
f 0
nc 3
nop 1
dl 0
loc 22
rs 8.6737
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\Indexing\ContentIndexing;
16
use eZ\Publish\SPI\Search\Indexing\FullTextIndexing;
17
use eZ\Publish\SPI\Search\Indexing\LocationIndexing;
18
19
/**
20
 * A Search Engine slot handling MoveUserGroupSignal.
21
 */
22
class MoveUserGroup extends AbstractSubtree
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\UserService\MoveUserGroupSignal || !$this->canIndex()) {
32
            return;
33
        }
34
35
        if (
36
            $this->searchHandler instanceof FullTextIndexing &&
37
            !$this->searchHandler instanceof ContentIndexing &&
38
            !$this->searchHandler instanceof LocationIndexing
39
        ) {
40
            return;
41
        }
42
43
        $userGroupContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
44
            $signal->userGroupId
45
        );
46
47
        // Moving UserGroup moves its main Location, so we only need to
48
        // (re)index main Location's subtree
49
        $this->indexSubtree($userGroupContentInfo->mainLocationId);
50
    }
51
}
52