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

Slot::canIndexLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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;
12
13
use eZ\Publish\Core\SignalSlot\Slot as BaseSlot;
14
use eZ\Publish\API\Repository\Repository;
15
use eZ\Publish\SPI\Persistence\Handler as PersistenceHandler;
16
use eZ\Publish\SPI\Search\Handler as SearchHandler;
17
use eZ\Publish\SPI\Search\Indexing;
18
use eZ\Publish\SPI\Search\Indexing\ContentIndexing;
19
use eZ\Publish\SPI\Search\Indexing\LocationIndexing;
20
21
/**
22
 * General slot implementation for Search Engines.
23
 */
24
abstract class Slot extends BaseSlot
25
{
26
    /**
27
     * @var \eZ\Publish\API\Repository\Repository
28
     */
29
    protected $repository;
30
31
    /**
32
     * @var \eZ\Publish\SPI\Persistence\Handler
33
     */
34
    protected $persistenceHandler;
35
36
    /**
37
     * @var \eZ\Publish\SPI\Search\Handler
38
     */
39
    protected $searchHandler;
40
41
    public function __construct(
42
        Repository $repository,
43
        PersistenceHandler $persistenceHandler,
44
        SearchHandler $searchHandler
45
    ) {
46
        $this->repository = $repository;
47
        $this->persistenceHandler = $persistenceHandler;
48
        $this->searchHandler = $searchHandler;
49
    }
50
51
    /**
52
     * Returns boolean indicating if the search engine can index Content or Location.
53
     *
54
     * To be handled in the concrete implementation.
55
     *
56
     * @return bool
57
     */
58
    protected function canIndex()
59
    {
60
        return $this->searchHandler instanceof Indexing;
61
    }
62
63
    /**
64
     * Returns boolean indicating if the search handler can index Content.
65
     *
66
     * To be handled in the concrete implementation.
67
     *
68
     * @return bool
69
     */
70
    protected function canIndexContent()
71
    {
72
        return $this->searchHandler instanceof ContentIndexing;
73
    }
74
75
    /**
76
     * Returns boolean indicating if the search handler can index Location.
77
     *
78
     * To be handled in the concrete implementation.
79
     *
80
     * @return bool
81
     */
82
    protected function canIndexLocation()
83
    {
84
        return $this->searchHandler instanceof LocationIndexing;
85
    }
86
}
87